I am new to selenium python and am trying to make a script to automate making appointments in a certain website however, a certain part of the code takes too long.
When a date is unavailable to schedule it just appears as normal text, but when it is available the element is changed and becomes a link to schedule an appointment so I wanted the script to keep refreshing until the date became available where then it would ignore the error and run the rest of the code.
Everything runs well except when the script tries to find the element, there is a delay before the error occurs so the rest of the code takes a while to load.
I was wondering if there was a way to remove the delay between the script looking for an element and the exception.
try:
unavailable_date = driver.find_element("xpath", '//*[@id="calendar"]/tbody/tr[4]/td[7]/font').is_enabled()
while unavailable_date:
driver.refresh()
except NoSuchElementException:
pass