Selenium page objects: one place for locators, and how to debug a failure
Move locators and steps into page object classes so a page change is fixed once, then learn a fixed routine for debugging a Selenium failure with screenshots and …
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: one phone directory for the whole office. When a number changes, the clerk updates the directory once. Every desk keeps working.
Tom uses a to centralize the synthetic Daily List screen's services and locators. records what happened in a particular run. A debug routine compares that evidence with the intended behavior before changing code.
One phone directory can reduce repeated contact details, but it does not guarantee that every call succeeds. Likewise, one shared can reduce duplication while still containing bugs.
The picture has a limit. A redesign may alter several components or behaviors, not just one locator. Business assertions belong in tests; a page object can verify that its expected page is loaded and ready when it is constructed.
(SYNTHETIC / TRAINING ONLY: Daily List and every named person are invented.)
PLAIN WORDS · 2 in this section
- debug
- find and fix faults in a program
- locator
- a pointer telling you where to find something
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Encapsulate page services and locators while keeping business assertions and failure diagnosis explicit.
- Directory
- Desks
- Log
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The directory | A page object |
| A desk | A test |
| A number changed in the directory | A locator changed once |
| A call log with notes | Failure evidence |
WHERE THIS PICTURE STOPS
- Centralization reduces duplication but does not guarantee that every redesign needs one edit.
- Tests retain business assertions; constructor readiness verification is a distinct documented exception.
HOOK
One directory, many desks.
TELL A FRIEND
A phone desk: update once.
OFTEN MIXED UP WITH Selenium waits: stop flaky tests by waiting for a condition. That topic waits for the page. This one organises a suite with page objects and finds faults in failures.
Sources & standards — 3 sources
- Market practice
Page object models — Selenium ↗ — Selenium project · Business assertions in tests; constructor readiness verification exception; page component objects (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Finding web elements — Selenium ↗ — Selenium project · First matching element in a given search context; scoping the search (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Waiting strategies — Selenium ↗ — Selenium project · Asynchronous readiness; implicit waits; explicit waits; warning not to mix waits (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
PRACTISE AND KEEP
Sources for this topic — 3 sources
- Market practice
Page object models — Selenium ↗ — Selenium project · Business assertions in tests; constructor readiness verification exception; page component objects (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Finding web elements — Selenium ↗ — Selenium project · First matching element in a given search context; scoping the search (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Waiting strategies — Selenium ↗ — Selenium project · Asynchronous readiness; implicit waits; explicit waits; warning not to mix waits (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.