Skip to content

QA-CS-106 — 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-CS-106.

FieldValue
Severitywarning
Confidencemedium
Tierquarantine
Measured FP rate33% (n=12)
Evidence levelE1
QA impactTest hygiene debt (HYGIENE)
False-positive risk (author estimate)medium
Autofix availableno
Languagescsharp
Frameworksnunit, xunit, mstest, 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-CS-106/must-fire/InventoryTests.cs

The fix ​

Prefer role-based locators (page.GetByRole(...)) or data-testid attributes.

Confirmed NOT to fire on the corresponding clean pattern ​

Verified against tests/fixtures/QA-CS-106/must-not-fire/RoleLocatorTests.cs — 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
microsoft-playwright-dotnet4
positive-fixtures3

Released under the MIT License.