Always look for implied services

Some of a page's services can be identified very clearly on it. And there are some services that are not visible on the page but that are implied. For example, in the All Posts page, we have identified five services just by looking at the page. But let's say your test case wants to know the count of existing posts; this information is available on the All Posts page, and we have to make sure that your PageObject provides that as an implied service. Now you extend your PageObject for the All Posts page with this implied service, which looks as follows:

public class AllPostsPage {

WebDriver driver;

@FindBy(id = "the-list")
WebElement postsContainer;

@FindBy(id = "post-search-input")
WebElement searchPosts;

@FindBy(id = "cat")
WebElement viewByCategories;

public AllPostsPage(WebDriver driver) {
this.driver = driver;
driver.get("http://demo-blog.seleniumacademy.com/wp/wp-admin/edit.php");
}

public void createANewPost(String title, String description) {
}

public void editAPost(String title) {
}

public void deleteAPost(String postTitle) {
}

public void filterPostsByCategory(String category) {
}

public void searchInPosts(String searchText) {
}

public int getAllPostsCount(){
}
}

Now your test cases can employ the same PageObject to use the implied services relevant to the All Posts page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.137.243