Complete the code to find the date picker element by its ID.
date_picker = driver.find_element(By.[1]("datePicker"))
The find_element method uses By.ID to locate the element with the specific ID "datePicker".
Complete the code to click the date picker element to open the calendar.
date_picker = driver.find_element(By.ID, "datePicker") date_picker.[1]()
Clicking the date picker element opens the calendar popup.
Fix the error in the code to select a date by visible text from the dropdown.
from selenium.webdriver.support.ui import Select month_dropdown = Select(driver.find_element(By.ID, "month")) month_dropdown.select_by_[1]("March")
The correct method to select an option by its visible text is select_by_visible_text.
Fill both blanks to create a dictionary comprehension that maps each day element's text to its WebElement if the day is greater than 15.
days = driver.find_elements(By.CLASS_NAME, "day") day_dict = {day.text: day for day in days if int(day.[1]) [2] 15}
We use day.text to get the day number as text, convert it to int, and check if it is greater than 15.
Fill all three blanks to create a test that asserts the selected date text matches the expected date.
selected_date = driver.find_element(By.ID, [1]).text expected_date = "2024-06-15" assert selected_date [2] expected_date, "Date does not match" print("Selected date is", [3])
The element ID is "selectedDate". We assert equality with ==. Finally, we print the variable selected_date.