We use analytics to count visits and form use. It is on unless you reject it. We show no ads on this site.

Glossary

Page object model (POM)

Published . Last updated . Published by Zapple.Tech, founded by the founders of CodeceptJS and Codeception, open-source testing frameworks.

Also called
POM, Page object pattern
Published
Updated
Definition

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.

Page object model: test code calls the actions of a page object, and the page object's locators find the elements on the page, so a changed label or button id is edited once, in the page object

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 expect inside 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.

  • 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.

All terms in the glossary

Service

Custom test framework development

Test automation framework development: a framework set up or reworked for your stack, repository and CI, from the founders of CodeceptJS and Codeception.

See the service

Questions about page object model

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.

Request a QA audit quote

Tell us what you ship and what worries you.

What happens after you send this

  1. You send the form: your situation and what you need tested, then your name and work email.
  2. Within one business day, we reply with a suggested first step, its scope, timeline and a quote.
  • Fixed scope
  • You decide after each step
  • The tests live in your repository
  • An NDA signed before access

“They helped us to close the positions and consult our team how to proceed further. High-quality quick feedbacks with the deep checking of the required tasks, professional approach, great understanding of the company's technologies and product, detailed reports.”

Kristina Lavrentieva, Manager at keepgo.com, Israel
  • Rated 4.9 out of 5 on Clutch, from 7 client reviews
  • 42 completed test automation and infrastructure projects
  • Founded by the founders of CodeceptJS and Codeception, open-source testing frameworks

Request a QA audit quote

    What is closest to your situation?
    Optional. The product, the platforms, how often you release, what broke last.

    You decide after our reply whether to go ahead.

    Prefer to talk first? Book a call

    One-week QA audit · written report

    Request a QA audit quote