0
0
Selenium Javatesting~10 mins

Date picker strategies in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to locate the date picker input field by its ID.

Selenium Java
WebElement dateInput = driver.findElement(By.[1]("datePicker"));
Drag options to blanks, or click blank then click option'
Aid
Bname
CclassName
DtagName
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.name or By.className when the element has a unique ID.
Trying to locate by tagName which is too generic.
2fill in blank
medium

Complete the code to select a date from the date picker by sending keys.

Selenium Java
dateInput.[1]("2024-07-15");
Drag options to blanks, or click blank then click option'
AsendKeys
Bclick
Cclear
Dsubmit
Attempts:
3 left
💡 Hint
Common Mistakes
Using click instead of sendKeys to enter text.
Using clear without sending keys afterwards.
3fill in blank
hard

Fix the error in the code to wait until the date picker calendar is visible.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.[1](ExpectedConditions.visibilityOfElementLocated(By.className("calendar")));
Drag options to blanks, or click blank then click option'
AwaitUntil
BwaitFor
Cuntil
DwaitForElement
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like waitFor or waitUntil.
Confusing wait methods with other WebDriver methods.
4fill in blank
hard

Fill both blanks to select a date from a calendar widget by clicking the correct day.

Selenium Java
WebElement calendar = driver.findElement(By.className("calendar"));
calendar.findElement(By.[1]("[2]"));
Drag options to blanks, or click blank then click option'
Axpath
BcssSelector
Cid
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using id or name which may not exist for day elements.
Using cssSelector without the correct selector string.
5fill in blank
hard

Fill all three blanks to create a map of dates and their availability status from the date picker.

Selenium Java
Map<String, Boolean> availability = new HashMap<>();
for(WebElement day : driver.findElements(By.className("[1]"))) {
    String date = day.getAttribute("[2]");
    boolean isAvailable = !day.getAttribute("class").contains("[3]");
    availability.put(date, isAvailable);
}
Drag options to blanks, or click blank then click option'
Aday-cell
Bdata-date
Cdisabled
Dcalendar-day
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong class names that do not match the date picker structure.
Confusing attribute names for dates or status.