First you click on the date picker input:
driver.find_element_by_xpath("//input[@id='hotel-checkin'").click()
then you expect the calendar to appear:
wait.until(lambda driver: driver.find_element_by_xpath("//div[@id='ui-datepicker-div']"))
then you click on it some date:
driver.find_element_by_xpath("//div[@id='ui-datepicker-div']//a[@class='ui-state-default'][text()='HERE_IS_DATE_LIKE_10']")).click() # meaning //div[@id='ui-datepicker-div']//td/a[@class='ui-state-default'][text()='10']
something like that. If you check the calendar using some browser tools, you will see that each "day" element has a td
element with the data-year
and data-month
attributes, and you can play around them. Like //div[@id='ui-datepicker-div']//td[@data-year='2014'][@data-month='8']/a[@class='ui-state-default'][text()='10']
source share