Testing / Playwright Interview questions
Explain the execution flow of a Playwright test?
A Playwright Test run moves through several distinct phases, from config resolution down to reporting, for every worker process.
flowchart TD
A[Load playwright.config.ts] --> B[Resolve projects and fixtures]
B --> C[Spawn worker processes]
C --> D[Launch browser per worker]
D --> E[Create isolated context and page fixtures]
E --> F[Run test body: actions and assertions]
F --> G{Passed?}
G -->|Yes| H[Teardown context]
G -->|No| I[Capture trace/screenshot, retry if configured]
I --> H
H --> J[Aggregate results into reporter output]
Each worker reuses its browser instance across tests for speed, but creates a brand-new isolated BrowserContext per test so no cookies, storage, or open pages leak between them. On failure, the configured artifacts (trace, screenshot, video) are captured before teardown, and if retries is set, the whole test body re-runs in a fresh context rather than resuming mid-test.
More Related questions...