I am automating a script to book appointments. Here is a snap of the datepicker. When available, dates are in green. datepicker
I can't know the attribute of the available dates until they are visible on the calendar. When available, they have no unique attribute to locate them with, they have a class and a title like unavailable dates and only the value changes.
<td class="day activeClass" title="Book">23</td>
I want to iterate all the dates, loop until i find available ones then select one of them.
After that comes the time of the appointment, which can be full even if the available date is in green. if an available time is there, i want to select it. If not, i want the script to go back to the available dates, select a different one then see if it has a available time. ( loop until time is available).
I started by locating the availables dates by Xpath, but i dont know how to do the rest.
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'))]")
I think that the datepicker is handled by somekind of js code i found in the sources but i am unable to paste it here for you to see it. How can i use that js code to serve my purpose?( iterate dates, loop available dates and times)
Solved
- ` can be used, or even just nested `
`. So maybe that site doesn't use `select`
– sound wave Feb 06 '23 at 11:45