Skip to content

QA-PY-104 — Brittle selector instead of role-based locator ​

← Back to the rule catalog

Generated from the rule registry. Get the same detail from the CLI with mjolnir explain QA-PY-104.

FieldValue
Severitywarning
Confidencemedium
Tierquarantine
Measured FP rate0% (n=10)
Evidence levelE1
QA impactTest hygiene debt (HYGIENE)
False-positive risk (author estimate)medium
Autofix availableno
Languagespython
Frameworkspytest-playwright, playwright
Detection strategyLEXICAL
Introduced inv0.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):

RepoOccurrences
positive-fixtures5

Released under the MIT License.