Skip to content
Development
Skill

/quality-engineering-selector-stability

Cross-stack selector and test-id policy for web and mobile automation. Use when writing or reviewing E2E/UI test locators, or adding data-testid/accessibility identifiers to components.

From plugin
agent-skills-standard
583200 skills21 agents33 commands1 MCP

Claude Code

$ npx -y skills add hoangnguyen0403/agent-skills-standard --skill quality-engineering-selector-stability --agent claude-code

SKILL.md

quality-engineering-selector-stability.SKILL.md
name: quality-engineering-selector-stability
description: Cross-stack selector and test-id policy for web and mobile automation. Use when writing or reviewing E2E/UI test locators, or adding data-testid/accessibility identifiers to components.
metadata:
  triggers:
    files:
      - "**/e2e/**/*.{ts,js}"
      - "**/*.e2e.{ts,js}"
    keywords:
      - selector
      - locator
      - data-testid
      - testID
      - accessibilityIdentifier
      - testTag
      - stable locator
      - selector drift

Quality Engineering: Selector Stability

**Priority: P0 (CRITICAL)**

Web Ladder

`getByRole` / `getByLabel` > `getByTestId` (`data-testid`) > attribute CSS. Never XPath, `nth-child`, or generated class names.

Mobile Ladder

Accessibility id > resource-id / `testTag` > predicate/uiautomator > XPath. Never XPath.

Framework Map

  • React/Next.js: `data-testid`.
  • React Native: `testID` for automation; separate `accessibilityLabel` for VoiceOver/TalkBack.
  • Flutter: `WidgetKeys` (`Key`) on widgets for widget tests, `integration_test`, and Patrol.
  • SwiftUI/UIKit: `.accessibilityIdentifier` (automation only); `.accessibilityLabel` (screen reader).
  • Jetpack Compose: `Modifier.testTag` + `testTagsAsResourceId = true` for automation; `contentDescription` for a11y.

Naming

`<screen>-<element>-<role>`, kebab-case (e.g. `checkout-submit-button`).

Insertion Policy

Add ids to leaf interactive/assertable elements only, never layout wrappers. Never rename an existing id — ids are a public contract other tests depend on.

Drift Classes

`rename` (id changed), `restructure` (DOM/tree moved), `i18n` (visible text changed, id untouched).

Collection Readiness

Prefer retrying assertions (`expect(locator).toHaveCount(...)`, `toHaveText([...])`) over immediate enumeration (`locator.all()`). `all()` samples count immediately and returns live positional locators without waiting, risking false-green empty iterations. Establish declared finite completion and exact expected identities before iterating. Never assume count alone freezes dynamic lists or guarantees membership stability; target elements by stable IDs via POM actions, never `.all()` indices.

Anti-Patterns

  • Text selectors on translated strings, index-based locators (`nth`), generated/hashed class names.
  • Using `accessibilityLabel` / `contentDescription` as a test id (they are user-facing a11y strings, not stable test locators).
  • Overwriting or stripping accessible labels to insert test identifiers.
  • Using web CSS / XPath selectors in native mobile automation.
  • "xpath just for now" — there is no temporary XPath; use the ladder from the first commit.
  • Immediate `locator.all()` loops on dynamic lists without asserting completion and identity readiness (causes false-green passes on empty lists).
  • Using `nth()` or `.all()` positional indices to target or mutate items; target by stable semantic IDs/keys through page objects instead.

References

  • [Selector Ladder Details](references/selector-ladder.md)
  • [Test-ID Naming](references/testid-naming.md)
  • [Insertion Policy](references/insertion-policy.md)
  • [Drift Classification](references/drift-classification.md)
  • [Collection Readiness & Dynamic Lists](references/collection-readiness.md)
Read more
@hoangnguyen0403
Ships withagent-skills-standard

The portable standards layer for AI coding agents. Sync once, then work in your own runtime.

583200 skills21 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
583
Star history of hoangnguyen0403/agent-skills-standard on GitHub, a chart by star-history.com

Other skills on agent-skills-standard.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills13d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react4d252k
@facebook@facebookInstall Skill

Questions about quality-engineering-selector-stability.

Which coding agents can use quality-engineering-selector-stability?
quality-engineering-selector-stability installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.