27. Automating Interactive Date Pickers in Python

Date Picker Automation in Python

# Open date picker:
driver.find_element(By.ID, "booking-date").click()

# Loop until desired month is displayed:
target_month = "November 2026"
while target_month not in driver.find_element(By.CLASS_NAME, "month-heading").text:
driver.find_element(By.CLASS_NAME, "next-arrow").click()

# Select day:
day_to_pick = "22"
driver.find_element(By.XPATH, f"//td[contains(@class, 'day') and text()='{day_to_pick}']").click()

Task

  • Implement click_calendar_day(driver, day_str):
  • 1. driver.find_element(By.XPATH, f"//td[text()='{day_str}']").click()
πŸ’‘Common doubts
Did you like the problem?
Lesson 27 of 43
Python
Loading code editor…
Next