Runbook 16 — Locator Intelligence Agent

Replace brittle manual locator authoring with a deterministic pipeline that discovers, validates, refines, and persists locator candidates as reusable artifacts.

Objective

Key shift

Locators are not manually guessed. They are derived from the live system, validated against reality, and refined until deterministic.

Definition of done

System overview

Flow
DISCOVERY → VALIDATION → REFINEMENT → ARTIFACTS → TESTS → RELEASE SIGNAL
Discovery Extract interactive elements from the live DOM.
Validation Check each locator candidate against the actual page.
Refinement Resolve ambiguity with scoped strategies or flag risk.
Artifacts Persist locator maps, validation results, and refinements as structured JSON.
Tests Use validated locators in Playwright instead of brittle hand-authored selectors.
Release signal Reduce locator-driven noise and improve CI trust.

Locator priority model

1. getByRole(role, { name })
2. getByLabel()
3. getByPlaceholder()
4. getByText()
5. CSS / XPath (last resort, high risk)
Risk model
  • LOW: unique role + accessible name
  • MEDIUM: repeated names or dynamic text
  • HIGH: brittle selectors or fallback-only strategies

Artifact contract

Canonical location test-results/locators/
Locator inventory locator-map.json
Validation results locator-validation.json
Refinement output locator-refinements.json
Recommended structure
/test-results/
  locators/
    locator-map.json
    locator-validation.json
    locator-refinements.json
Critical

These artifacts allow debugging without reruns and power downstream intelligence.

Commands

Discover, validate, refine

# Discover
node scripts/run-locator-extraction.js

# Validate
node scripts/validate-locators.js

# Refine
node scripts/generate-scoped-candidates.js
Operator rule

If a locator is ambiguous, do not guess. Scope it, validate it, or fix accessibility.

Validation outcomes

Expected outputs

Failure modes

Connection to the intelligence layer

Outcome

Locator quality directly impacts release confidence.

Operational value