Playwright strict mode violation
A Playwright locator expected to identify one element matched more than one, so Playwright refused an ambiguous action.
RECOGNIZABLE ERROR
Error: strict mode violation: locator('button') resolved to 2 elementsRANKED DIAGNOSIS
What usually causes it
- 01
The accessible name is duplicated
Two controls now share the role and name used by the locator.
DIAGNOSE
Inspect every match and confirm whether the product created a duplicate control.
FIX
Add a unique accessible name or stable test id at the product boundary.
- 02
A broad CSS or text selector is being used
The selector describes appearance or copy rather than the intended control contract.
DIAGNOSE
Compare the current selector with getByRole, getByLabel, and getByTestId candidates.
FIX
Use the narrowest user-facing locator that remains unique.
- 03
A hidden duplicate remains in the DOM
Responsive or transitional UI may render two copies while only one is visible.
DIAGNOSE
Check visibility and responsive containers for every match.
FIX
Remove the duplicate from the DOM when inactive or scope the locator to the active region.
Prevent the repeat
- →Verify locator uniqueness in component tests.
- →Prefer role and accessible name contracts.
- →Avoid positional `.first()` as a repair.
Primary references
Run this against your evidence
The browser triage workflow uses the same stable pattern slug and does not upload your paste.