Skip to main content
Test Automation

Page Object Model (POM)

A design pattern that creates an object-oriented representation of web pages to separate test logic from page structure.

Full definition

Page Object Model (POM) is a design pattern widely used in test automation that creates a class for each web page or component. Each page object encapsulates the page's elements and actions, keeping test code clean and maintainable.

Without POM (fragile): ``` await page.click('#login-btn'); await page.fill('#user-email', 'test@test.com'); ```

With POM (maintainable): ``` const loginPage = new LoginPage(page); await loginPage.login('test@test.com', 'password'); ```

Benefits:

  • Single responsibility: If a locator changes, update one place
  • Reusability: Login action used across many tests
  • Readability: Tests read like user stories
  • Maintainability: UI changes require updating page objects, not tests

Best practices:

  • One page object per page/component
  • Expose only meaningful actions (not raw elements)
  • Return new page objects for navigation (login() returns DashboardPage)
  • Don't put assertions in page objects — keep them in tests

Interview tip

POM comes up in almost every automation interview. Know the pattern, its benefits, and be ready to implement a simple page object.

Learn more about page object model (pom) in practice

Automation track