Skip to main content

What is Auto-waiting?

Playwright automatically waits for elements to be ready before performing actions. This eliminates the need for manual waits and makes tests more reliable.
Unlike many testing frameworks that require explicit waits, Playwright waits automatically for actionability checks.

Actionability Checks

Before performing an action, Playwright waits for the element to pass several checks:
1

Attached

Element is attached to the DOM
2

Visible

Element is visible (not display: none, visibility: hidden, empty width/height, etc.)
3

Stable

Element is not animating or moving
4

Enabled

Element is not disabled (for input elements)
5

Editable

Element is not readonly (for input actions like fill)
6

Receives Events

Element is not covered by other elements

Automatic Waiting in Action

You rarely need explicit waits with Playwright. Trust the auto-waiting!

Actions with Auto-waiting

All these actions wait automatically:

Click Actions

Input Actions

Selection Actions

Locator Auto-waiting

Locators wait automatically when performing actions:
From client/locator.ts:75-90:

Wait States

Playwright supports different wait states:

attached

visible

hidden

detached

Navigation methods wait for the page to load:

Load States

  • load - load event fired (default)
  • domcontentloaded - DOMContentLoaded event fired
  • networkidle - No network connections for 500ms
  • commit - Navigation committed, DOM is interactive
From client/frame.ts:111-115:

Explicit Waits

When auto-waiting isn’t enough, use explicit waits:

waitForSelector

waitForLoadState

waitForURL

waitForFunction

waitForEvent

waitForRequest

waitForResponse

waitForTimeout

Avoid waitForTimeout unless absolutely necessary. Use condition-based waits instead.

Retries and Stability

Playwright retries checks until they pass or timeout:

Stability Checks

Playwright ensures elements are stable before interacting:
From the server implementation, stability checks:
  1. Take two element positions
  2. Wait 100ms
  3. Compare positions
  4. Retry if positions changed

Visibility Checks

Elements must be visible to interact:
Visibility criteria:
  • Not display: none
  • Not visibility: hidden
  • Not opacity: 0
  • Has size (width > 0 and height > 0)
  • Not behind other elements

Editable Checks

Input elements must be editable:
Editable criteria:
  • Not readonly
  • Not disabled
  • Is an input element

Enabled Checks

Enabled criteria:
  • Not disabled attribute
  • Not inside disabled fieldset
  • Not disabled via ARIA

Timeout Configuration

Default Timeouts

Per-action Timeouts

Best Practices

Don’t add unnecessary explicit waits.
Choose the right wait state for navigation.
Use waitForFunction for complex conditions.
Wait for content to stabilize.

Debugging Waits

Common Patterns

Wait for Multiple Elements

Wait for API Response

Wait for Navigation

Wait for Element Count

Error Messages

When waits timeout, Playwright provides helpful errors:

Next Steps

Test Isolation

Ensuring test independence

Assertions

Testing expectations

Debugging

Debugging failed tests