Playwright deep dive
Auto-waiting and actionability checks, web-first assertions, fixtures, trace viewer, network interception, parallel workers. The current default for new suites.
The mental model
Playwright is a remote-control cable to a real browser, not a browser and not a screen-scraper. Your test process runs in Node (or Python/Java/.NET); the browser runs as a separate process; between them sits one persistent WebSocket carrying a stream of commands and events. You never touch the DOM directly — you send an instruction ("click the element matching this locator"), and the browser-side agent executes it against the live page and reports back.
The analogy that sticks: Playwright is a **patient surgical assistant**, where Selenium's classic model was a **fire-and-forget mail carrier**. Old WebDriver sent "click at these coordinates" and hoped the element was there; if it wasn't, you got a NoSuchElementException and reached for sleep(). Playwright's assistant is told "click the Checkout button" and waits until the button is actually clickable — visible, stable, enabled, hit-testable — before touching it, then retries the whole thing if the page mutates underneath.
The one idea that explains most of Playwright's behaviour: **a locator is a lazy query, not an element.** page.getByRole('button') captures no element — it captures a recipe for finding one. The DOM is only queried at the moment of an action or assertion, and re-queried on every retry. This is why Playwright survives React re-renders that detach and re-attach nodes: the stale-element problem that plagues Selenium simply cannot happen, because there is no element handle to go stale. Auto-waiting and web-first assertions are both direct consequences of this laziness — understand it and the rest of the API stops surprising you.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision