Skip to main content
InterviewHubPRO
Section Overview
Q20

Question 20 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

40%
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:
    1. Is the element attached to the DOM?
    2. Is it visible?
    3. Is it stable (not animating or transitioning)?
    4. Is it enabled (not disabled)?
    5. 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.