For sites where SSH isn't available, we drive maintenance through Playwright by automating the WordPress admin UI. Plugin updates, theme updates, translation updates — all running fine. Until one day, only the Core (WordPress itself) update started failing.

The error was Locator.click: strict mode violation — familiar to anyone who's used Playwright, the one that fires when a locator matches multiple elements. Tracing it back, the root cause turned out to be a structural quirk of the WordPress admin UI sitting right at the trap line. This post walks through the bug from the angle of Playwright's strict mode and making .first a habit.

Strict mode violation is "your selector is too lenient" telling you something

Playwright locators run in strict mode by default. Code like page.locator('input[name="upgrade"]').click() will fail with this error if two or more matching elements exist on the page:

Locator.click: strict mode violation: