Bird
0
0

What is wrong with this multi-page navigation code?

medium📝 Debug Q7 of 15
Selenium Java - Page Object Model
What is wrong with this multi-page navigation code?
driver.get("https://example.com/start");
driver.findElement(By.id("next")).click();
String title = driver.getTitle();
assert title.equals("Page 2 Title");
Adriver.get() should be driver.navigate()
BIncorrect assertion syntax
CUsing id locator is invalid
DNo wait after click before getting title
Step-by-Step Solution
Solution:
  1. Step 1: Detect timing issue after navigation click

    No wait after click risks title retrieval before page load. Others valid: get() correct, assertion syntax ok, id locator fine.
  2. Final Answer:

    No wait after click before getting title -> Option D
  3. Quick Check:

    Wait for page load before assertions [OK]
Quick Trick: Always wait for page load before assertions [OK]
Common Mistakes:
MISTAKES
  • Skipping waits causing flaky assertions
  • Misusing assertion syntax
  • Confusing driver.get() and navigate()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes