I am trying to code a script to book appointments inside this datepicker.
When available, the dates are in green. The problem is I don't know when they can be available to locate them directly with an attribute ( class or title...)
Selecting an available date triggers a drop-down list for appointment time and another one for visa type( hidden elements)
How can I :
1/Iterate all dates, loop until available ones are found, select one of them?
2/Iterate appointment times ,loop until available ones are found and select one of them?
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
import sys
available_dates = driver.find_elements(By.XPATH, "//div[@class='datepicker-days']/table/tbody/tr/td[not(contains(@class, 'disabled'))]")
for date in available_dates:
print(date.text)
Line of code 23th September
<td class="day activeClass"title="Book">23</td>