As plain as possible. Two criteria to extend pageObjects beyond retrieving DOM elements:
-
Something is done LOTS of times
-
It generates LOTS of codelines.
Always use methods to retrieve DOM elements so we always get an updated version on element (and prevents referencing stale elements)
Avoid:
class AppPage {
public submitButton;
constructor() {
this.submitButton = element(by.className('login-btn');
}
}
Prefer:
class AppPage {
constructor() {}
getSubmitButton() {
return element(by.className('login-btn'));
}
}
Use ExpectedConditions:
let loadingSpinner = element(by.className('spinner'));
browser.wait(ExpectedConditions.not(ExpectedConditions.presenceOf(loadingSpinner)), 15000, 'Loading too slow.');