TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
Playwright / Chapter 43 of 60~18 min • Beginner
Chapter 43Playwright

Auto-waiting and timeouts

Playwright checks actionability before many actions, including visibility, stability, event reception and enabled state where relevant. Different operations have different checks. Test, action and assertion timeouts are distinct. Use observable readiness rather than sleep.

How it works

Step-by-step walkthrough

  1. Create a disabled button
  2. Enable it after a delay
  3. Let the locator wait

Example

TypeScript
import { test, expect } from '@playwright/test';

test('chapter 43 practice', async ({ page }) => {
  await page.setContent('<button disabled>Save</button><script>setTimeout(() => document.querySelector("button").disabled = false, 500)</script>');
  await page.getByRole('button', { name: 'Save' }).click();
  await expect(page.getByRole('button')).toBeEnabled();
});
Expected result: Click waits until the button becomes enabled
💡 Point to remember
Avoid page.waitForTimeout in production tests.

Practice application screenshot

Actual screenshot of the TestingDocs task manager practice application
TestingDocs practice page, captured in Chromium.

✎ Your practice task

Increase the delay and observe the behavior.

Knowledge check

What should replace a fixed sleep for a visible element?

🌐 Continue learning