Challenge - 5 Problems
Multi-page Navigation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium Java code snippet?
Consider the following Selenium Java code that navigates through two pages and checks the title of the second page. What will be printed to the console?
Selenium Java
WebDriver driver = new ChromeDriver(); driver.get("https://example.com/page1"); String title1 = driver.getTitle(); driver.findElement(By.id("nextPageLink")).click(); new WebDriverWait(driver, Duration.ofSeconds(5)) .until(ExpectedConditions.titleContains("Page 2")); String title2 = driver.getTitle(); System.out.println(title2); driver.quit();
Attempts:
2 left
💡 Hint
Think about what happens after clicking the link and waiting for the new page title.
✗ Incorrect
The code navigates to page1, clicks a link to page2, waits until the title contains 'Page 2', then prints the title. So the output is the title of page 2.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies the URL after navigation?
After clicking a link that navigates to "https://example.com/dashboard", which assertion correctly verifies the current URL in Selenium Java?
Selenium Java
driver.findElement(By.linkText("Dashboard")).click(); // Wait for navigation to complete new WebDriverWait(driver, Duration.ofSeconds(5)) .until(ExpectedConditions.urlToBe("https://example.com/dashboard"));
Attempts:
2 left
💡 Hint
Check which assertion exactly matches the expected URL.
✗ Incorrect
assertEquals compares the current URL exactly to the expected URL, ensuring precise verification after navigation.
🔧 Debug
advanced2:00remaining
Why does this multi-page navigation test fail intermittently?
This Selenium Java test clicks a link to navigate to a new page and then asserts the page title. Sometimes it fails with an AssertionError. What is the most likely cause?
Selenium Java
driver.findElement(By.id("profileLink")).click(); assertEquals(driver.getTitle(), "User Profile");
Attempts:
2 left
💡 Hint
Think about page load timing and synchronization.
✗ Incorrect
Without waiting, the test may check the title before the new page loads, causing intermittent failures.
❓ locator
advanced2:00remaining
Which locator is best for clicking a 'Next' button in a multi-page flow?
You want to click the 'Next' button to go to the next page in a multi-page form. The button has the text 'Next' and a class 'btn-next'. Which locator is the best practice in Selenium Java?
Attempts:
2 left
💡 Hint
Consider specificity and stability of locators.
✗ Incorrect
By.cssSelector("button.btn-next") is specific, stable, and less brittle than XPath or linkText for buttons.
❓ framework
expert3:00remaining
How to design a robust multi-page navigation test framework in Selenium Java?
Which approach best supports maintainability and reliability for multi-page navigation tests in Selenium Java?
Attempts:
2 left
💡 Hint
Think about code reuse, readability, and synchronization.
✗ Incorrect
Page Object Model with explicit waits improves code reuse, readability, and handles timing issues robustly.