In the Page Object model, we separate page UI elements and Test methods. However, there is a concept of Page chaining, in which we return an object on the next Page Object in the previous page object method. Now, I don't use this in my Cucumber BDD Selenium+Java framework as not every page object calls the next page. I use the PageFactory pattern.
- Some page objects perform some actions like Edit user profiles, search user, etc... Is it a bad practice not to return the instance of the next Page class in the chain?
- Also, I don't create a separate Page Object java class for each page in my application. I make PageObject per functionality, not per page. Like only AddContacts.java, not for the Edit Contact page, View Contact page, etc. Is it again acceptable?
- What is the difference between the page factory and the POM model? In the page factory, we don't return page objects in methods.
Also, are there some resources on the theory of Page object chaining/pattern?
public HomePage loginToSite(String username, String password)
{
uName.sendKeys(username);
pWd.sendKeys(password);
loginBtn.click();
return new HomePage();
}