QA-PY-104 — Brittle selector instead of role-based locator
Generated from the rule registry. Get the same detail from the CLI with
mjolnir explain QA-PY-104.
| Field | Value |
|---|---|
| Severity | warning |
| Confidence | medium |
| Tier | quarantine |
| Measured FP rate | 0% (n=10) |
| Evidence level | E1 |
| QA impact | Test hygiene debt (HYGIENE) |
| False-positive risk (author estimate) | medium |
| Autofix available | no |
| Languages | python |
| Frameworks | pytest-playwright, playwright |
| Detection strategy | LEXICAL |
| Introduced in | v0.4.0 |
Why this fails in production
XPath paths and structural CSS break on any markup refactor and silently select the wrong element after redesigns.
What gets flagged (real detector output)
Brittle selector (xpath= selector).Example from this rule's own must-fire fixture: tests/fixtures/QA-PY-104/must-fire/test_inventory_selectors.py
The fix
Prefer role-based locators (get_by_role(...)) or data-testid attributes.
Confirmed NOT to fire on the corresponding clean pattern
Verified against tests/fixtures/QA-PY-104/must-not-fire/test_role_selectors.py — a legitimate, similar-looking pattern this rule correctly leaves alone.
Corpus-measured false-positive risk
Real occurrence counts from npm run corpus:audit against actively-maintained OSS repos — reproduce yourself, don't just trust this table (see the false-positive audit):
| Repo | Occurrences |
|---|---|
| positive-fixtures | 5 |