Skip to content
vefimofff edited this page Dec 26, 2017 · 21 revisions

Page class basically represents the entire browser window with all content. It contains all possible actions and checks that a user can do on a page.

All page classes should extend AbstractPage class.

Methods

Follow single responsibility principle while developing page methods. Each method should represent one action that user can do on a page. Hint: if method name contains "And" word in it - it is probably a good candidate for change.

Important: Grouping actions in a sequence is not a responsibility of a Page

Сonsider

inputLogin() {
    element(By.id("inputLogin").sendKeys("login");
}

inputPassword() {
    element(By.id("inputPassword").sendKeys("password");
}

clickLoginButton() {
    element(By.id("loginButton").click();
}

Instead of

login() {
    element(By.id("inputLogin").sendKeys("login");
    element(By.id("inputPassword").sendKeys("password");
    element(By.id("loginButton").click();
}

Class

Pages easily get overload with different actions and become quite hard to use and maintain. You don't want to grow a monster, do you? That's why you must keep all your Page classes less than 300 LoC.

Splitting page into blocks (aka page objects) will help to keep your page nice and clean.

Clone this wiki locally