What is Page Object Model (POM)?
The Page Object Model (POM) is a design pattern in test automation where each web page or component is represented by a class that encapsulates its elements and interactions, separating test logic from UI details.
Free to start · 7-day trial on paid plans
In depth.
Without POM, test scripts directly reference locators and UI actions, creating duplication across tests. When a UI element changes, you update every test that touches it. POM centralizes page elements and actions in one class per page. Tests call high-level methods like loginPage.signIn(email, password) instead of repeating find-element-click-type sequences.
A well-designed Page Object exposes methods that represent user actions (fillEmail, submitForm, getErrorMessage), hides locator strategies and implementation details, returns other Page Objects for navigation (clicking "checkout" returns a CheckoutPage), and avoids assertions inside Page Objects, keeping them in the test layer.
POM scales through composition. Complex pages can delegate to Component Objects (e.g., a NavBar component used across multiple Page Objects). For single-page applications with dynamic content, some teams adopt the Screenplay pattern or App Actions pattern, but POM remains the most widely used and interview-relevant pattern.
Two anti-patterns account for most POM failures in the wild. The first is assertions inside page objects: once a page object asserts, it hard-codes one test's expectation into a class shared by many tests, so keep page objects returning state (getErrorMessage(), isLoaded()) and let each test decide what to assert. The second is the god object, a single Page class that accumulates hundreds of methods for every widget on a complex screen; the cure is composition, splitting the page into component objects (NavBar, SearchResults, FilterPanel) that the page object exposes as properties.
The Screenplay pattern is the main alternative worth knowing. Where POM models pages, Screenplay models actors who perform tasks composed of interactions (actor.attemptsTo(Login.withCredentials(...))), which scales better for long multi-persona workflows and reads closer to business language; Serenity BDD popularized it in the Java world. The honest trade-off is that Screenplay brings a steeper learning curve and more indirection, so most teams get further with disciplined POM plus component objects, and interviewers mostly expect you to know Screenplay exists and when its task-first modeling pays off.
Implementation differs meaningfully between Selenium and Playwright. In Selenium, page objects typically hold By locators plus a WebDriver injected through the constructor, often with PageFactory and @FindBy annotations in Java, and every interaction needs explicit waits (WebDriverWait) baked into the methods. In Playwright, the page object receives a Page and stores Locator fields (this.submitButton = page.getByRole('button', { name: 'Sign in' })), which are lazily evaluated and auto-waiting, so the wait plumbing that dominates Selenium page objects largely disappears. Playwright's fixture system also lets you inject fully constructed page objects into tests, replacing the manual new LoginPage(driver) wiring.
Why interviewers ask about this.
POM is the most-asked design pattern question in SDET and automation interviews. Interviewers want to see that you write maintainable, DRY test code, not throwaway scripts.
Example scenario.
A LoginPage class has methods enterEmail(email), enterPassword(password), and clickSignIn() that return a DashboardPage. When the dev team changes the Sign In button from a <button> to an <a> tag, only the LoginPage class needs updating. All 30 tests that use it continue to pass without modification.
Interview tip.
Be ready to code a simple Page Object on a whiteboard. Show that methods return Page Objects for chaining, and explain why you keep assertions in the test layer rather than the Page Object.
Frequently asked questions.
Should page objects contain assertions?
The classic guidance is no: page objects should return state (getErrorMessage(), isLoaded()) and let each test decide what to assert, because baking one test's expectation into a shared class couples every other test to it. A pragmatic exception is a lightweight loaded-check that waits for a key element. Keeping assertions in the test layer keeps page objects reusable across tests with different expectations.
What is the difference between the Page Object Model and the Screenplay pattern?
POM organizes automation around pages: one class per page exposing user actions. Screenplay organizes it around actors who perform tasks composed of interactions (actor.attemptsTo(Login.withCredentials(...))), which scales better for long multi-persona workflows and reads closer to business language. Screenplay adds indirection and a steeper learning curve, so most teams stay with POM plus component objects unless workflow complexity demands more.
How do you implement the Page Object Model in Playwright?
Create a class that takes the Page in its constructor and stores Locator fields built with user-facing selectors like page.getByRole(...). Expose methods for user actions and return other page objects from navigation methods. Because Playwright locators auto-wait, you skip the explicit wait plumbing Selenium page objects need, and you can inject fully constructed page objects into tests through Playwright fixtures.
Why should page object methods return other page objects?
Returning the next page object models real navigation: loginPage.signIn() returns a DashboardPage because that is where a successful sign-in lands. It enables fluent chaining, and in typed languages the compiler catches impossible flows, such as calling a dashboard method before login. Methods that keep you on the same page return this (or void) instead.
Is the Page Object Model still relevant in 2026?
Yes. Auto-waiting locators and AI-assisted locator healing have removed boilerplate, not the underlying problem: without a page layer, every UI change still fans out across every test that touches the element. POM remains the default expectation in automation interviews, with Screenplay and component objects as the variations worth knowing.
Related Terms
Explore related glossary terms to deepen your understanding.
Related Resources
Dive deeper with these related interview prep pages.
Free QA career tools, no account needed
Instant and private, everything runs in your browser. Try them before you sign up.
QA Resume Checker
Instant 0-100 score on automation keywords, impact, and ATS formatting.
QA Cover Letter Generator
A tailored 3-paragraph QA cover letter from your resume and a job post.
QA Application Tracker
Drag-and-drop kanban to track every QA application from Applied to Offer.
QA Take-Home Test Generator
A realistic take-home assignment with a scenario, tasks, and a rubric.
QA LinkedIn Headline Generator
A recruiter-searchable headline, About section, and skills list.
QA STAR Story Builder
Structure a QA behavioral answer with the STAR method and instant checks.
QA Bug Report Generator
Build a clean, reproducible bug report for Markdown, Jira, or plain text.
Boundary Value Analysis Generator
Generate boundary value and equivalence partitioning test cases from a range.
QA Metrics Calculator
Calculate DRE, defect leakage, defect density, and pass rate with interpretation.
QA Test Plan Generator
Build a structured test plan (scope, approach, criteria, risks) in Markdown.
QA Salary Calculator
Estimate QA, SDET, and automation tester pay by level, market, and skills.
QA Offer Evaluator
See total comp, a counter range, and a ready-to-send negotiation message.
Ready to Ace Your QA Interview?
Practice explaining page object model (pom) and other key concepts with our AI interviewer.
Join 1,200+ QA engineers already practicing with AssertHired.
Start your free QA interviewCurious how it works first? See the QA mock interview