Skip to content

QA-SE-002 — Hard sleep before element lookup (C#, missing WebDriverWait) ​

← Back to the rule catalog

Generated from the rule registry. Get the same detail from the CLI with mjolnir explain QA-SE-002.

FieldValue
Severitywarning
Confidencemedium
Tierquarantine
Measured FP rate8% (n=13)
Evidence levelE2
QA impactFlaky-test risk (FLAKY-RISK)
False-positive risk (author estimate)medium
Autofix availableno
Languagescsharp
Frameworksselenium
Detection strategyLEXICAL (sequence shape: Thread.Sleep/Task.Delay followed by a FindElement/interaction call within 3 lines (code-only view))
Introduced inv0.6.0

Why this fails in production ​

The sleep is standing in for an explicit wait: the element lookup after it still races the app, so the test is both slow (always sleeps) and flaky (races when the app is slow to render).

What gets flagged (real detector output) ​

Hard sleep before an element lookup (sleep at line 10) — the explicit-wait substitute (QA-SE-002).

Example from this rule's own must-fire fixture: tests/fixtures/QA-SE-002/must-fire/InventoryTest.cs

The fix ​

Replace the sleep with an explicit wait: Java new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfElementLocated(...)); C# new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(...); Python WebDriverWait(driver, 10).until(EC.visibility_of_element_located(...)).

Confirmed NOT to fire on the corresponding clean pattern ​

Verified against tests/fixtures/QA-SE-002/must-not-fire/LoginFlowsTests.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
positive-fixtures2
SeleniumHQ-selenium4

Released under the MIT License.