Selenium + Python · Lesson 27 of 43
Module 27: Calendars & Date Pickers
Your task
Implement click_calendar_day(driver, day_str):
Write it in the editor, then press Check answer (Ctrl + Enter).
# 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()Date pickers vary from standard input fields to dynamic popup calendars. In this lesson, you will master navigating calendar months in a loop and clicking the target day cell. Let's master date pickers!
Part of the Selenium + Python course (Selenium with Python). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.
Yes, if the input is not marked readonly, driver.find_element(...).send_keys('11/22/2026') is much faster and simpler.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___