Software Testing & QA (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
Playwright Auto-Waiting and Web-First Assertions: Why `sleep()` is an anti-pattern.
senior LevelTestingSystem Design
In Simple Words:
Traditional Selenium tests required arbitrary sleeps (sleep(3000)), causing test suites to take hours while remaining flaky under CI load.
Playwright Auto-Waiting:
- Before clicking, Playwright automatically checks:
- Is the element attached to the DOM?
- Is it visible?
- Is it stable (not animating or transitioning)?
- Is it enabled (not disabled)?
- Is it not obscured by other overlay elements?
- Web-First Assertions (
expect(locator).toBeVisible()): Continuously polls the DOM until the condition is met or the timeout (default 5s) expires.