Selenium For Beginners

Share this post

User's avatar
Selenium For Beginners
Avoid method coupling
Page Class

Avoid method coupling

Alex Siminiuc's avatar
Alex Siminiuc
May 24, 2023
∙ Paid

Share this post

User's avatar
Selenium For Beginners
Avoid method coupling
Share

The following test method is our starting point:

@Test
public void canSearchTest() {
   HomePage homePage = new HomePage(driver);
   homePage.open();

   Assert.assertTrue(homePage.isDisplayed(), "home page is not displayed!");

   ResultsPage resultsPage = homePage.searchBy(KEYWORD);

   Assert.assertTrue(resultsPage.isDisplayed(), 
      "results page is not displayed!");

   resultsPage.getResultsInfo();

   Assert.assertTrue(resultsPage.getTotalCount() > 0, 
      "total Count is not positive!");
}

The following 2 lines get our attention:

resultsPage.getResultsInfo();

Assert.assertTrue(resultsPage.getTotalCount() > 0, 
   "total Count is not positive!");

The 1st line gets the results info from the page, the 2nd one gets the total count.

How do they work?

Keep reading with a 7-day free trial

Subscribe to Selenium For Beginners to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Alex Siminiuc
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share