Bird
0
0

Consider this code:

medium📝 Predict Output Q5 of 15
Selenium Java - Page Object Model
Consider this code:
driver.get("https://example.com/start");
driver.findElement(By.linkText("Next")).click();
String title = driver.getTitle();
System.out.println(title);

If the next page title is "Example - Page 2", what will be printed?
AExample - Page 1
Bstart
CExample - Page 2
DThrows NoSuchElementException
Step-by-Step Solution
Solution:
  1. Step 1: Analyze navigation and title retrieval after click

    Clicking link navigates to page 2, so getTitle() returns "Example - Page 2", printed by System.out.println(title).
  2. Final Answer:

    Example - Page 2 -> Option C
  3. Quick Check:

    Page title after navigation = "Example - Page 2" [OK]
Quick Trick: getTitle() returns current page title after navigation [OK]
Common Mistakes:
  • Expecting old page title after navigation
  • Confusing linkText locator with id
  • Assuming NoSuchElementException without checking element

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes