You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Automatic waiting to resolve strict mode violations #36045
When there is a strict mode violation, instead of immediately raising an exception, wait the usual time for the strict mode violation to resolve
Example
In a test scenario, where an open dialog should be closed by clicking the close button:
awaitpage.getByLabel('close').click();
If there are still some auto-disappearing toast messages visible on the page, and they have a dismiss-button with the same label, the test will immediately crash.
Instead, each action that would raise a strict-mode-violation should first perform an expect wait like from the workaround, and only actually fail when the violation is still present after the timeout.
Motivation
It would make workarounds like above unnecessary, and also align the code generated from the recording feature more aligned with the actual working test code.
Reacted by David Cloutier, Son Thanh Nguyen, russell-aciss, Aaron Pool, Henry Cai, temi oduyemi, MiladSadinam, Imthiyaz H, Roman Starkov, dab-abittner and 2 more
Reacted by temi oduyemi, ternshare and MiladSadinam
Please this really should be a high priority. Playwright touts its auto-waiting and retry-ability especially when it comes to Locators. This behaviour has been documented (#30363) to be throwing false negatives for a while now.
Currently I have multiple flaky test scenarios where I navigate to a new page, then click on a button. Playwright throws a strict mode violation while the new page has barely started loading, due to the previous page having elements that match the button Locator. I've currently worked around around with load state waits, but even that's still inconsistent, i might have to turn to hard waits.
This behaviour of throwing an error and failing the test before the browser has even registered the previous action violates the philosophy of Locators and their in-built auto-wait and auto-retry mechanism. This is the exact sort of flakey behaviour that playwright locators are designed to avoid. Why are strict-mode errors a fail-fast exception to this?
It really is an odd choice. Waiting for success is one of the genius ideas that Playwright great. But the reality is this: zero matches = wait, two matches = insta-fail. Just why?
Use case: React 19 has forced me to use startTransition on navigations, which means that click is not immediately followed by the current page disappearing. Every single test that happens to match two things on the old screen is now broken, and we have a lot of tests that match on simple selectors like "button titled Edit".
I seem to be having a similar issue in vaadin ui with a select drop down. I still don't know why, but i'm randomly getting strict mode violation because it finds the same item in a select drop down twice. When the run fails, it usually fails on a different value available in the select drop down.
We can't get it to fail running it during the day so for sure a few milliseconds of waiting time to see if the violation disappears by itself wouldn't be a huge issue.
We're closing all P3-collecting-feedback issues and retiring the label. #43813 explains why. This doesn't mean the request is wrong. If it still matters to you, please open a new issue against the latest Playwright version with your concrete use case and link back here.
Activity
dacloutier-logmein commentedon May 30, 2025
I like the idea, also had to cope with similar problems.
toduyemi commentedon Nov 17, 2025
Please this really should be a high priority. Playwright touts its auto-waiting and retry-ability especially when it comes to Locators. This behaviour has been documented (#30363) to be throwing false negatives for a while now.
Currently I have multiple flaky test scenarios where I navigate to a new page, then click on a button. Playwright throws a strict mode violation while the new page has barely started loading, due to the previous page having elements that match the button Locator. I've currently worked around around with load state waits, but even that's still inconsistent, i might have to turn to hard waits.
This behaviour of throwing an error and failing the test before the browser has even registered the previous action violates the philosophy of Locators and their in-built auto-wait and auto-retry mechanism. This is the exact sort of flakey behaviour that playwright locators are designed to avoid. Why are strict-mode errors a fail-fast exception to this?
MiladSadinam commentedon Nov 27, 2025
I would also highly appreciate this, as we regularly have flaky strict mode violations because there is no auto-waiting on that check.
It is just practically not feasible to add everywhere
.toHaveCount(1)when the framework could take over this job.toduyemi commentedon Jan 29, 2026
Is there any update or discussion to this? This issue stays cropping up.
rstarkov commentedon Mar 3, 2026
It really is an odd choice. Waiting for success is one of the genius ideas that Playwright great. But the reality is this: zero matches = wait, two matches = insta-fail. Just why?
Use case: React 19 has forced me to use startTransition on navigations, which means that
clickis not immediately followed by the current page disappearing. Every single test that happens to match two things on the old screen is now broken, and we have a lot of tests that match on simple selectors like "button titled Edit".markustauscher commentedon Apr 20, 2026
I seem to be having a similar issue in vaadin ui with a select drop down. I still don't know why, but i'm randomly getting strict mode violation because it finds the same item in a select drop down twice. When the run fails, it usually fails on a different value available in the select drop down.
We can't get it to fail running it during the day so for sure a few milliseconds of waiting time to see if the violation disappears by itself wouldn't be a huge issue.
pavelfeldman commentedon Oct 31, 2026
We're closing all
P3-collecting-feedbackissues and retiring the label. #43813 explains why. This doesn't mean the request is wrong. If it still matters to you, please open a new issue against the latest Playwright version with your concrete use case and link back here.