POM Purpose
Page Object Model separates test intent from raw Selenium operations.
Tests say what to do. Pages know how to do it.
A reference for building maintainable Selenium frameworks with page objects, reusable layers, logging, reporting, and CI-ready structure.
Page Object Model separates test intent from raw Selenium operations.
Tests say what to do. Pages know how to do it.
Keep locators and actions in page classes, not in tests.
public class LoginPage {
By email = By.id("email");
By password = By.id("password");
By loginButton = By.id("login");
}
Move shared utilities into a base layer only when multiple pages need them.
public class BasePage {
protected WebDriver driver;
public BasePage(WebDriver driver) {
this.driver = driver;
}
}
PageFactory is useful to know, especially in interviews and legacy frameworks.
@FindBy(id = "email") WebElement email; PageFactory.initElements(driver, this);
Headers, modals, and repeated widgets deserve their own reusable classes.
Examples: - HeaderComponent - SidebarComponent - CartModal
Use data objects instead of long parameter lists when flows grow.
public class LoginData {
public String username;
public String password;
}
Frameworks should explain failures quickly, not just fail silently.
Common reporting pieces: - Log4j - ExtentReports - screenshots on failure - execution metadata
Retries can reduce noise, but failure evidence still matters.
On failure: - capture screenshot - log locator/action context - attach to report - mark retried state clearly
Keep framework responsibilities separated and obvious.
src/main/java/pages src/main/java/utils src/test/java/tests src/test/resources/testdata reports/