Back to All Questions
Question 3 of 100
Mechanics
Beginner
What is Auto-Waiting in Playwright?
The Answer
Auto-waiting is Playwright's built-in mechanism that checks 5 actionability conditions before executing any action. It eliminates the #1 cause of flaky tests: timing issues.
Deep Dive Explanation
The 5 actionability checks are evaluated using JavaScript injected into the browser, polling via requestAnimationFrame (tied to the browser's render cycle). This makes it more precise than Selenium's polling mechanism. The default timeout is 30 seconds per action, configurable per-action or globally.
example.spec.ts
// No sleep() or waitForElement() needed!
await page.getByRole('button', { name: 'Submit' }).click();
// β Playwright automatically waits until the button is:
// β
Attached to the DOM
// β
Visible (not hidden/display:none)
// β
Stable (not animating)
// β
Receives events (not covered by overlay)
// β
Enabled (not disabled attribute)
// Only if ALL 5 pass β Playwright clicks