What is page object model?
The page object model is a test design pattern that wraps each page or component in a class exposing user actions.
Instead of repeating locators in every test, a page object such as LoginPage offers methods like signIn(email, password). When the UI changes, only the page object needs updating.
It improves readability and maintenance, though modern locator strategies and self-healing reduce how much of it teams need.
Example
Fifty tests sign in through LoginPage.signIn(). When the sign-in button text changes, one line in the page object is updated instead of fifty tests.
Best practices
- Expose user intentions, not raw elements
- Keep assertions in tests, not page objects
- Group by page or reusable component
- Avoid deep inheritance hierarchies
Ship without fear.
Start testing free in minutes, or let a QAShift engineer deliver your first morning report within 5 days.