selectors-collectorlisted
Install: claude install-skill YevheniiaQA/qa-agent-toolkit
# Selectors Collector
Locator quality determines suite lifespan. A suite built on CSS paths dies at the
next refactor; a suite built on roles and test IDs survives redesigns.
## Locator priority
Use the first strategy that uniquely identifies the element:
1. **`getByTestId`** — `data-testid` on elements the tests depend on. The only
locator the application explicitly promises to keep stable.
2. **`getByRole` with an accessible name** — `getByRole('button', { name: 'Connect' })`.
Doubles as an accessibility assertion: if this locator cannot find the element,
a screen reader user cannot find it either.
3. **`getByLabel`** for form controls — likewise ties the test to a real
accessibility contract.
4. **`getByPlaceholder` / `getByText`** — acceptable when the copy is stable and
the app is single-locale.
5. **CSS scoped to a semantic container** — a last resort, and only with a comment
explaining why nothing better was available.
Never generate: absolute XPath, `nth-child` chains, class names that look
generated (`css-1x2y3z`, Tailwind utility stacks), or text matching against copy
that the design marks as provisional.
## Never anchor on visible text in a localised application
Check the rendered language before writing a single locator. `<html lang="ru">`
means every text-based locator you write from an English mental model will match
nothing — and the failure is silent in the worst way: a negative assertion passes
because the element was never found.
Th