Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am automating a script to book appointments.

Here is a snap of the datepicker. When available, dates are in green. https://www.linkpicture.com/q/Sans-titre_5.jpg[^]

I can't know the attribute of the available dates until they are visible on the calendar.

I want to find a way to iterate all dates in the datepicker, loop until available dates are found then select one of them randomly.

What I have tried:

all_dates = driver.find_elements(By.XPATH, "//div[@class='datepicker-days']/table/tbody/tr/td")
for date in all_dates:
    if date == driver.find_element(By.XPATH, "//div[@class='datepicker-days']/table/tbody/tr/td[not(contains(@class, 'disabled'))]"):
        date.click()
        break
    else:
        driver.refresh()
Posted
Updated 3-Feb-23 5:09am
v3
Comments
Elouali Issam 3-Feb-23 14:58pm    
Anyone please?
Elouali Issam 5-Feb-23 16:07pm    
Hello

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900