I am scraping a website using selenium python to take an appointment. I click on the calendar to chose which date is available, and the available dates are on green.
HTML code of the calendar:
The available dates have the same attribute
title, , so I made the following Xpath to find them,
It works, and I print them using a for loop:
Output:
When I click on a day, if there's an available time, I can continue filling the form normally, but when there is no time available during that day, it shows an error message
What I want to do is to iterate through those available dates, pick a time if it's available and continue filling the form. If there is no time available and it shows an error message, I want to go to the next date and repeat the process until I find an available time.
I made the following script to click on date
23, but I'm not sure if it's going to work or not because the dates are no longer available and I can't
test it out.
The problem is that the available dates don't have any different attribute that I can locate them with, so I don't know how can I iterate through them. Each row is represented by
tr attribute with an index from
1 to
6. And each
tr has
7tds, for example, the Xpath of the date
23 is
I had the idea of appending the available dates in a list and iterate through it, but I can't do that because I can't locate them automatically. I'm really stuck at this point and I really need help. I hope I made what I want to do obvious.