60 / 139 · 13 Browser Automation with Playwright · Setup and First Test← prev⊞ allnext →☰ Read as one page
5.5The Test Runner: `@playwright/test`
Playwright ships with its own test runner that provides features other frameworks require plugins for:
| Feature | Playwright Built-in | Selenium Equivalent |
|---|---|---|
| Parallel execution | Yes (workers) | External (Grid, pytest-xdist) |
| Test retries | retries: 2 in config |
External plugin |
| Screenshots on failure | Automatic | Manual setup |
| Video recording | video: 'on-first-retry' |
Third-party tool |
| Trace viewer | Built-in timeline debugger | No equivalent |
| HTML reporter | reporter: 'html' |
Allure, ExtentReports |
Basic Configuration
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
timeout: 30_000,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 4 : undefined,
use: {
baseURL: 'http://localhost:3000',
screenshot: 'only-on-failure',
trace: 'on-first-retry',
},
projects: [
{ name: 'chromium', use: { browserName: 'chromium' } },
{ name: 'firefox', use: { browserName: 'firefox' } },
{ name: 'webkit', use: { browserName: 'webkit' } },
],
});