# Page object model (POM)

> Page Object Model: What It Is and When It Pays Off. Canonical page: <https://zapple.tech/glossary/page-object-model/>

The page object model (POM) is a design pattern for UI test automation in which each page or part of an application is represented by a class that holds its locators and the actions a user can take there. Tests call those methods instead of repeating selectors, so a change in the interface is fixed in one place.

## Why do teams use the page object model?

A UI test has to find things on a screen: a login field, a pay button. If every test repeats the selector for that button, one redesign breaks every test that touches it, and someone edits the same line in every one of them. The page object model puts the selectors for a screen in one class and gives tests plain actions such as "log in" or "apply a discount code".

The [Playwright documentation](https://playwright.dev/docs/pom) says page objects simplify authoring by creating a higher-level API and simplify maintenance by capturing element selectors in one place. The [WebdriverIO documentation](https://webdriver.io/docs/pageobjects) puts the goal this way: store the selectors that are unique to a page in its page object, so you can still run your tests after you have completely redesigned the page. The Selenium project documents the same pattern, and its [page object guide](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) was last modified on 2026-09-16.

For you as a QA lead, the pattern is a maintenance decision, not a style choice. It decides how many places a UI change touches and who can fix a broken suite.

## When is the page object model worth it, and when is it not?

Our rule of thumb: use it when many tests share screens. A checkout, a login and a settings page are visited by dozens of tests, and each of those screens changes often. One owner for each screen's selectors makes a red build after a redesign a small, local fix.

We would skip it in three cases:

- **A small or short-lived suite.** With a dozen tests that each touch a different screen, the extra classes cost more reading time than they save.
- **Tests that mostly call an API.** There is no screen to wrap.
- **A team that already uses helper functions well.** Plain functions for "log in" and "add to cart" give a similar saving with less structure. The [Cypress best practices](https://docs.cypress.io/app/core-concepts/best-practices) list sharing page objects among their anti-patterns and advise isolated specs and direct control of application state instead, so the pattern is not universal.

If you are choosing a structure for a new suite, our post on [QA practices for a test automation framework](/blog/types-of-automation-testing/the-best-test-automation-practice/) covers where it fits next to other decisions. If the decision is to restructure an existing suite, see [custom framework development](/services/custom-framework-development/).

## Page objects or inline locators: which fits your suite?

| | Inline locators in each test | Page objects |
|:--|:--|:--|
| Where a selector lives | Repeated in every test that uses it | Once, in the page object |
| When the UI changes | Edit every test that touches the element | Edit one class |
| Cost up front | None | A class per page or component |
| Reading a test | Selectors and steps mixed together | Steps in business words |
| Risk | Slow, repetitive fixes | Page objects grow into large, shared classes |
| Choose it when | Few tests share a screen, the suite is small or short-lived, or tests mostly call an API | The same screens appear in many tests and those screens change often |
| Who fixes a broken test | Whoever can read every test and its selectors | The owner of that screen's page object |

How much you save depends on how many tests share each screen and how often that screen changes.

## What mistakes do teams make with page objects?

- **One giant class per page.** A page with a header, a table and a dialog is better as several small objects. The pattern's name suggests one object per page; the unit that fits is a meaningful part of the screen.
- **Assertions hidden inside page objects.** The Selenium documentation says page objects should never make verifications or assertions, apart from checking that the page loaded. The example in the Playwright documentation puts an `expect` inside a method. Decide as a team, because mixed styles make failures hard to read.
- **Locators tied to layout.** Playwright's [best practices](https://playwright.dev/docs/best-practices) recommend prioritizing user-facing attributes and explicit contracts, such as role, text and test id locators, over selectors tied to CSS classes and DOM structure. A page object full of long CSS paths moves the fragility into one file without removing it.
- **Sharing state between tests through page objects.** The WebdriverIO guide treats a page as a stateless construct and says state changes should live in the tests.
- **Applying the pattern everywhere by habit.** API-level tests and one-off screens do not need a class; see "When is the page object model worth it" above.

Not everyone agrees the pattern is the right default. In [Flow Model vs Page Object Pattern](/blog/aqa-process/peter-foldhazi-jr-flow-model-vs-page-object-pattern/), Péter Földházi Jr argues that page objects break the Single Responsibility principle and presents the Flow Model as an alternative. The talk recording is on this site's blog. The related [codeless test automation guide](/blog/types-of-automation-testing/what-is-codeless-test-automation-and-which-tools-you-need-for-it/) covers tools that avoid code altogether.

## What does Zapple.Tech do about it?

If your suite breaks on every UI change, the first question is where the fragility sits: selectors, test data, waits or the pipeline. Zapple.Tech starts with a one-week QA audit of one product area. It looks at its tests, pipeline and release process, and ends in a written report on what is at risk and what to fix first, plus a pilot plan you can run with Zapple.Tech or without it. Read more on the [QA audit and assessment](/services/audit-and-assessment/) page.

When the audit points to a framework problem, [custom framework development](/services/custom-framework-development/) covers the rebuild. Tell us about your suite in the form below. More terms are in the [QA glossary](/glossary/).

## FAQ

### What is the page object model?

The page object model (POM) is a design pattern for UI test automation. Each page or part of an application is represented by a class that holds its locators and the actions a user can take there. Tests call those methods instead of repeating selectors, so a change in the interface is fixed in one place. Playwright describes a page object as representing a part of your web application.

### Should a page object contain assertions?

The two main sources differ. The Selenium documentation says page objects should never make verifications or assertions, apart from a check that the page loaded. The example class in the Playwright documentation has an expect inside a page object method. One middle path is to keep checks in the tests and let the page object expose the state to check. Pick one rule and apply it everywhere.

### Does the page object model reduce test maintenance?

It moves the edit to one place. The Playwright documentation says page objects simplify maintenance by capturing element selectors in one place. That helps when many tests touch the same screen. It is extra code to write and read, so a small suite with few repeated screens may not earn the saving back.

### Do I need the page object model if I use Playwright or Cypress?

No. Both tools work without it. Playwright documents the pattern as one option for structuring a suite, and Cypress lists sharing page objects among its anti-patterns. Teams use it when the same screens appear in many tests, and skip it when helper functions are enough.

## Sources

- [Selenium documentation, Page object models (last modified 2026-09-16)](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/)
- [Playwright documentation, Page object models](https://playwright.dev/docs/pom)
- [Playwright documentation, Best practices](https://playwright.dev/docs/best-practices)
- [WebdriverIO documentation, Page object pattern](https://webdriver.io/docs/pageobjects)
- [Cypress documentation, Best practices](https://docs.cypress.io/app/core-concepts/best-practices)
