Actionability
Buttons that exist but cannot be clicked yet: disabled, covered, moving or out of view.
Actionability checks
Before click(), Playwright waits until the element is:
- visible: it has a size and is not hidden;
- stable: it is not moving or animating;
- receiving events: no other element covers it;
- enabled: not disabled.
It also scrolls the element into view. So on this page, a plain click() works everywhere. Playwright waits, without any extra code from you:
await page.getByRole('button', { name: 'Prepare order' }).click();
// "Submit order" is disabled for 2 seconds. click() waits for it.
await page.getByRole('button', { name: 'Submit order' }).click();Reading the error when it never becomes actionable
If the wait runs out, the error says exactly which check failed, for example:
- element is not enabled
- <div class="loading-overlay">…</div> intercepts pointer events
- element is not stableThat message is a clue about your app, not just about your test.
Why force: true is a trap
click({ force: true }) skips the checks and clicks wherever the element is. If an overlay is on top, the click lands on the overlay, so nothing happens, but the test step still passes. Try it on the Export button while the overlay is showing, then assert the result.
await page.getByRole('button', { name: 'Refresh data' }).click();
await page.getByRole('button', { name: 'Export' }).click({ force: true });
await expect(page.getByTestId('export-result')).toHaveCount(0); // nothing was exportedforce when you know why the check fails and the user could still do it. That is rare.Enabled after a delay
"Submit order" becomes enabled 2 seconds after you prepare.
Covered by an overlay
Refreshing covers the panel with a loading overlay for 2.5 seconds.
Moving into place
The offer slides in over 1.5 seconds.
Out of view
The button is at the bottom of a scrollable box.
Section 1. These terms are long on purpose, so the button below starts out of view.
Section 2. These terms are long on purpose, so the button below starts out of view.
Section 3. These terms are long on purpose, so the button below starts out of view.
Section 4. These terms are long on purpose, so the button below starts out of view.
Section 5. These terms are long on purpose, so the button below starts out of view.
Section 6. These terms are long on purpose, so the button below starts out of view.
Section 7. These terms are long on purpose, so the button below starts out of view.
Section 8. These terms are long on purpose, so the button below starts out of view.
Section 9. These terms are long on purpose, so the button below starts out of view.
Section 10. These terms are long on purpose, so the button below starts out of view.
Section 11. These terms are long on purpose, so the button below starts out of view.
Section 12. These terms are long on purpose, so the button below starts out of view.
Related exercises
- Debugging & TracingBeginnerReading FailuresRead five different Playwright errors and fix each test from what the error says.
- Dynamic ElementsAdvancedFlaky LabMake tests that pass every time, then prove it by running them many times.
- Dialogs & WindowsIntermediateModals & OverlaysTest modals built into the page: native and custom, stacked, and one that interrupts you.
Read the guide: Playwright auto-waiting: how to fix flaky tests