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 says page objects simplify authoring by creating a higher-level API and simplify maintenance by capturing element selectors in one place. The WebdriverIO documentation 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 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 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 covers where it fits next to other decisions. If the decision is to restructure an existing suite, see 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
expectinside a method. Decide as a team, because mixed styles make failures hard to read. - Locators tied to layout. Playwright’s 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, 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 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 page.
When the audit points to a framework problem, custom framework development covers the rebuild. Tell us about your suite in the form below. More terms are in the QA glossary.
How does page object model relate to other terms?
- Data-driven testing
Data-driven testing runs one test over many sets of input and expected values kept apart from the test logic. You write the check once and add cases as rows of data. It pays off when one flow must work for many inputs, such as prices, locales or user roles, and it is overkill for a handful of cases.
- Self-healing test automation
Self-healing test automation is tooling that tries to repair an automated test on its own when the application changes, for example by finding a moved element through another locator. A person still has to check each repair. Our test automation maintenance fixes broken and flaky tests, uses self-healing where your framework supports it, and reviews every repair.
- Regression testing
Regression testing confirms that a change, including a defect fix, has caused no adverse consequences. The same checks are run many times, which makes it a strong candidate for automation. Our regression testing services build an automated regression suite in your repository that runs in your CI before every release, with every red run triaged.
Sources
- Selenium documentation, Page object models (last modified 2026-09-16) (read 5 December 2026)
- Playwright documentation, Page object models (read 5 December 2026)
- Playwright documentation, Best practices (read 5 December 2026)
- WebdriverIO documentation, Page object pattern (read 5 December 2026)
- Cypress documentation, Best practices (read 5 December 2026)