Whenever we are designing an automation framework for testing web applications, we have to accept the fact that the target application and its elements are bound to change. An efficient framework is one that needs minimal refactoring to adapt to new changes in the target application. Let's try to build the preceding test scenarios into the PageObject design pattern model. Let's first start building a PageObject for the login page. This should look like the following:
public class AdminLoginPage {
WebDriver driver;
WebElement email;
WebElement password;
WebElement submit;
public AdminLoginPage(WebDriver driver) {
this.driver = driver;
driver.get("http://demo-blog.seleniumacademy.com/wp/wp-admin");
email = driver.findElement(By.id("user_login"));
password = driver.findElement...