Thursday, December 3, 2026 | London 11°C · Drizzle
DailyGlimpse

AI

Understanding Playwright's Auto-Wait: A Smarter Alternative to waitForTimeout()

PRASAD REDDY TECH 1 min read

If you're still relying on waitForTimeout() in your Playwright tests, it's time to switch to a more efficient approach. Playwright's Auto-Wait feature automatically waits before performing user actions, enabling cleaner, faster, and more reliable automation.

What is Auto-Wait?

Auto-Wait is a built-in mechanism that waits for elements to meet specific conditions before executing actions like click(), dblclick(), check(), uncheck(), fill(), clear(), hover(), dragTo(), tap(), selectOption(), and setInputFiles(). It applies to most locator actions that interact with the page.

Actionability Checks Performed

Before an action, Playwright verifies:

  • The element is attached to the DOM
  • The element is visible
  • The element is stable (not animating)
  • The element is enabled
  • The element can receive pointer events

Default Timeout

Playwright waits up to 30 seconds by default before throwing a TimeoutError. You can customize this using page.setDefaultTimeout() or configure it globally in playwright.config.ts.

Debugging Tips

To see Auto-Wait in action, run tests with debugging enabled:

  • DEBUG=pw:api npx playwright test – shows every API call and automatic waiting.
  • npx playwright test --debug – opens Playwright Inspector for step-through debugging.
  • PWDEBUG=1 npx playwright test or --headed mode.
  • Use Playwright Trace Viewer with --trace on for detailed traces.

Mastering Auto-Wait is essential for efficient Playwright development. Avoid flaky tests by letting Playwright handle waiting intelligently.

React