0
0
Selenium Javatesting~10 mins

Why advanced skills handle complex scenarios in Selenium Java - Test Your Understanding

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

Complete the code to open a browser and navigate to a URL.

Selenium Java
WebDriver driver = new ChromeDriver();
driver.[1]("https://example.com");
Drag options to blanks, or click blank then click option'
Aget
Bstart
Copen
Dnavigate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'navigate' instead of 'get' causes compilation errors.
2fill in blank
medium

Complete the code to find a button by its ID and click it.

Selenium Java
WebElement button = driver.findElement(By.[1]("submitBtn"));
button.click();
Drag options to blanks, or click blank then click option'
AtagName
Bname
CclassName
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' or 'className' when the element has an ID.
3fill in blank
hard

Fix the error in the code to wait until an element is visible before clicking.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.[1](By.id("loginBtn")));
driver.findElement(By.id("loginBtn")).click();
Drag options to blanks, or click blank then click option'
AelementToBeClickable
BvisibilityOfElementLocated
CpresenceOfElementLocated
DelementToBeSelected
Attempts:
3 left
💡 Hint
Common Mistakes
Using presenceOfElementLocated may cause errors if element is hidden.
4fill in blank
hard

Fill the blank to create a test that asserts the page title contains a word.

Selenium Java
String title = driver.getTitle();
assertTrue(title.[1]("Example"));
Drag options to blanks, or click blank then click option'
Aequals
BstartsWith
Ccontains
DendsWith
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equals' checks exact match, not containment.
5fill in blank
hard

Fill both blanks to create a map of element texts filtered by length.

Selenium Java
Map<String, Integer> lengths = elements.stream()
  .filter(e -> e.getText().length() [1] 3)
  .collect(Collectors.toMap(e -> e.getText(), e -> e.getText().[2]()));

lengths.forEach((k, v) -> System.out.println(k + ": " + v));
Drag options to blanks, or click blank then click option'
A>
Blength
Clength()
DtoUpperCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'length' without parentheses causes errors.