Page Object Model Training

The training covers everything that you need to know about Page Object Model.

Page Object Model helps writing short, easy to understand and easy to modify automated tests.

Without Page Object Model, a Selenium tests is very long and difficult to read:

@Test

public void expandedSearchReturnsMoreResults() {

 

  driver.get(URL);

 

  assertEquals(driver.getCurrentUrl(), "Vancouver Public Library",

"home page url is incorrect!");

  

  WebElement searchBox = driver.findElement(SEARCH_BOX_ID);

  searchBox.sendKeys("java");

  WebElement searchButton = driver.findElement(SEARCH_BUTTON_ID);

  searchButton.click();

  assertEquals(driver.getCurrentUrl(), "Search - Vancouver Public Library",

"results page url is incorrect!");

  WebElement resultsCountLabel = driver.findElement(RESULTS_COUNT_ID);

  String resultCountText = resultsCountLabel.getText();

  int i1 = resultsCountText.indexOf("of ") + 3;

  int i2 = resultsCountText.indexOf(" results");

  String countText = resultsCountText.substring(i1, i2);

  int initialCount = Integer.parseInt(countText);

  WebElement broadenSearchLink = driver.findElement(BROADEN_SEARCH_ID);

  broadenSearchLink.click();

  assertEquals(driver.getCurrentUrl(), "searchScope",

"expanded results page url is incorrect!");

  resultsCountLabel = driver.findElement(RESULTS_COUNT_ID);

  resultCountText = resultsCountLabel.getText();

  i1 = resultsCountText.indexOf("of ") + 3;

  i2 = resultsCountText.indexOf(" results");

  countText = resultsCountText.substring(i1, i2);

  int finalCount = Integer.parseInt(countText);

  assertTrue(initialCount < finalCount, "final count is not greater than the initial count!");

}

With the help of Page Object Model, the previous test can be changed so that anyone can understand what it does:

@Test

public void expandedSearchReturnsMoreResults() {

  HomePage homePage = new HomePage(driver);

  homePage.open();

  

  ResultsPage resultsPage = homePage().searchBox().searchFor("java");

  int initialCount = resultsPage.resultsCount().value();

  resultsPage = resultsPage.broadenSearch();

  int finalCount = resultsPage.resultsCount().value();

  assertTrue(initialCount < finalCount, "final count is not greater than the initial count!");

}

The new test created with the Page Object Model is not only much shorter than the first one but much easier to read, even by people with no coding knowledge.

It is easier to understand because it uses objects that correspond to site pages instead of Selenium WebDriver objects.

Duration: 2 days (Saturday + Sunday, April 27 - 28, 2019)

10 seats

Price: 450

Early bird price: $350 (until March 31, 2018)

CURRICULUM

DAY 1

Theory and Implementation of Page Object Model

  1. Convert a manual test case to a format that is suitable for automation

  2. Components of a page class

  3. Create page classes for all site pages involved in the test case

  4. Use the page classes objects in the automated test

  5. Return page objects from page methods

  6. Reduce the size of the page classes by creating page component classes

  7. Reduce the number of assertions from the test

  8. Page Factory

  9. Combine Page Object Model with Page Factory

  10. Custom Page Factory

DAY 2

Practice Page Object Model

  1. Practice Page Object Model through multiple  exercises

  2. Feedback on each solution

 

  3. Group Discussions

   

 Contact me at alex@alexsiminiuc.com for additional info.

© 2018 Vancouver Selenium WebDriver Automation Training