Bird
0
0

Consider this test class snippet:

medium📝 Predict Output Q5 of 15
Selenium Java - Page Object Model
Consider this test class snippet:
public class SearchTest {
  SearchPage searchPage = new SearchPage(driver);

  @Test
  public void testSearch() {
    String result = searchPage.search("Selenium");
    Assert.assertEquals(result, "No results found");
  }
}
If the search method returns "Results found", what will happen?
ACompilation error due to missing imports
BTest fails due to assertion mismatch
CTest passes successfully
DTest throws NullPointerException
Step-by-Step Solution
Solution:
  1. Step 1: Check expected vs actual values

    Expected is "No results found", actual is "Results found".
  2. Step 2: Assert equals behavior

    Since values differ, assertion fails causing test failure.
  3. Final Answer:

    Test fails due to assertion mismatch -> Option B
  4. Quick Check:

    AssertEquals(mismatch) = Fail test [OK]
Quick Trick: AssertEquals fails if strings differ [OK]
Common Mistakes:
MISTAKES
  • Assuming test passes despite different strings
  • Confusing assertion failure with exceptions
  • Ignoring case sensitivity in strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes