Testing / Playwright Interview questions
What happens when a Playwright locator doesn't match any element within the timeout?
Playwright doesn't fail instantly the moment zero elements match - it keeps re-querying the DOM throughout the action's timeout window (30 seconds by default for actions), since the element might simply not have rendered yet.
Once the timeout elapses with still no match, Playwright throws a TimeoutError with a detailed message describing exactly what it was waiting for - the locator's selector, which actionability check (if any element was found but not ready) was last failing, and a snapshot of the attempted retries. This is deliberately more diagnostic than a generic "element not found" error, since it distinguishes "nothing ever matched" from "something matched but was never clickable."
If tracing is enabled, this failure also gets captured with a DOM snapshot at the moment of timeout, making it possible to see exactly what the page actually looked like instead of just an error string.
More Related questions...