Page Object Model and framework architecture
The Page Object Model (POM) — a pattern gathering each page/component's locators and actions into one class:
- Locator changes are fixed in ONE place
- Tests read in business language:
await loginPage.loginAs(user) - Duplication disappears
Rules: page objects don't assert (that's the test's job; they only return state), actions are user-level (fillCheckoutForm(data), not clickElement(selector)), small components get their own objects (Header, CartWidget).
A full framework layout: pages/ (POMs), fixtures/, api/ (clients), test-data/ (factories), utils/, tests/ (specs — scenario logic only).
Middle interviews also ask for POM's CRITIQUE: deep inheritance hierarchies (BasePage → ... → 5 levels) are an anti-pattern; modern alternatives favour composition and lighter "screenplay" / component-object approaches. Balance: keep POMs simple, don't write a method for every UI detail.
📚 Sources and documentation
- Page Object Modelofficialplaywright.dev