Testing / Playwright Interview questions
Explain the internal working of Playwright's auto-waiting and actionability checks?
Before executing an action, Playwright doesn't just check the target element once - it runs a continuous polling loop, re-evaluating every relevant actionability check on every animation frame until all of them pass simultaneously or the timeout expires.
flowchart TD
A[Action called, e.g. click] --> B[Resolve locator to element]
B --> C{Attached?}
C -->|No| B
C -->|Yes| D{Visible & stable?}
D -->|No| B
D -->|Yes| E{Enabled?}
E -->|No| B
E -->|Yes| F{Receives events at target point?}
F -->|No| B
F -->|Yes| G[Perform action]
The "stable" check specifically compares the element's bounding box across two consecutive animation frames - if it hasn't moved, it's considered done animating. The "receives events" check performs a hit-test at the element's center point and confirms the resolved locator's element (not some other overlapping element) is actually what would receive the click, which is what catches cases like a modal overlay silently swallowing clicks meant for content behind it. Only once every check passes on the same iteration does Playwright dispatch the real input event, rather than after the first partial success.
More Related questions...