QA Test Lab • Runbook 08
← Back to Runbooks Sprint Plan

Runbook 08 — Page Objects at scale (pages/components/flows)

Quick links

Scope

Rule

Specs describe workflows. Pages/components/flows implement mechanics. Assertions are centralized.

Exit criteria

Structure

pages/
  HomePage.*
  LoginPage.*
  SettingsPage.*
  EditorPage.*
  ArticlePage.*
  ProfilePage.*

components/
  Navbar.*
  ArticlePreview.*
  TagList.*

flows/
  AuthFlow.*
  PublishArticleFlow.*
  FollowUserFlow.*

assertions/
  expectLoggedIn.*
  expectArticleVisible.*
  expectToast.*

helpers/
  env.*
  urls.*
  dataFactories.*
Rule

One responsibility per layer: page = screen, component = reusable UI chunk, flow = cross-page task, assertion = reusable expectation set.

Locator policy

Default getByRole + accessible name
Next getByLabel (forms) / getByPlaceholder (only if stable)
Next getByTestId (when accessibility name not stable or not available)
Escalation CSS selector anchored to stable attribute (document why)
Disallowed index selectors, deep DOM traversal, brittle chains, “works today” XPath
Rule

If CSS is required, include the justification in the page object as a comment adjacent to the locator.

POM contract

Flows

New page procedure

  1. Create pages/NewFeaturePage.* with open() and assertAt().
  2. Add locators using locator policy (role/label/testid first).
  3. If UI chunk repeats, create a components/ object and reference it from the page.
  4. If the task crosses pages, create/extend a flows/ helper.
  5. Add/extend assertion helpers in assertions/ for repeated checks.
  6. Add one recipe spec proving page + component + flow integration.
Definition

UI change should update 1–2 files (page/component/flow). Specs should not require bulk edits.

PR review checks

Optional enforcement
# detect hardcoded URLs and raw selectors in specs
grep -R "http://" -n specs pages components flows assertions || true
grep -R "https://" -n specs pages components flows assertions || true

# discourage inline locator patterns in specs
grep -R "getByRole\\(|getByLabel\\(|getByTestId\\(|locator\\(" -n specs || true

Commands

Set env contract:

export WEB_BASE_URL="http://sut.testlab:3000"
export API_BASE_URL="http://sut.testlab:3001/api"

Run Sprint 8 recipe spec:

npx playwright test specs/sprint8 \
  --project=auth-chromium --workers=1 --reporter=line
Project names

Use auth-chromium / unauth-chromium per the config. Do not use --project=chromium unless it exists.

Expected outputs

Failure modes

System flow

UPSTREAM Sprint 07 — Fixtures (execution control)
Sprint 05 — Test data (state correctness)
CURRENT LAYER UI abstraction layer (this runbook)
Converts raw UI into stable domain actions
DOWNSTREAM Sprint 14 — Failure artifacts
Sprint 15 — Failure classification
Sprint 17 — Release decisions
Why this matters

If UI abstraction is unstable, all downstream signals (failures, triage, release gates) become unreliable.