Playwright
Complete reference for Playwright — the cross-browser end-to-end testing framework by Microsoft for reliable web automation
Installation & Setup
Installing Playwright and creating your first project
Create New Project
Initialize a new Playwright test project with all dependencies
Configuration File
Set up playwright.config.ts with projects, reporters, and options
Writing Tests
Test structure, hooks, and organizing test suites
Basic Test Structure
Write tests with test blocks, navigation, and assertions
Test Hooks & Grouping
Organize tests with describe blocks and lifecycle hooks
Locators
Finding elements on the page with built-in locator strategies
Built-in Locators
Use role-based, text, and semantic locators to find elements
Actions & Interactions
Clicking, typing, selecting, and interacting with page elements
Common Actions
Click, type, select, check, and interact with elements
Assertions
Web-first assertions that auto-wait and auto-retry
Page & Element Assertions
Assert on page state, element visibility, text content, and attributes
Emulation & Devices
Emulate mobile devices, viewports, geolocation, locale, and color schemes
Device & Viewport Emulation
Test on mobile devices, custom viewports, and different screen configurations
Locale, Timezone & Geolocation
Emulate user locale, timezone, geolocation, permissions, and color scheme
Visual & Snapshot Testing
Compare screenshots and snapshots against golden baselines
Screenshot Comparisons
Capture and compare page or element screenshots against baselines
Parallelism & Sharding
Run tests in parallel across workers and shard across CI machines
Parallel Execution & Sharding
Configure parallel workers and split test suites across CI machines
Retries & Timeouts
Configure test retries for flaky tests and set timeout boundaries
Configuring Retries
Automatically retry failed tests to handle flaky behavior
Timeout Configuration
Set timeouts for tests, actions, navigation, and assertions
Navigation & Waiting
Page navigation, waiting strategies, and auto-wait behavior
Navigation
Navigate between pages and wait for load states
Network Mocking & Interception
Intercept, mock, and modify network requests and responses
Mock API Responses
Intercept API calls and return custom data without hitting the server
API Testing
Test REST APIs directly without browser UI using the request fixture
API Requests
Send HTTP requests directly to test your API endpoints
Fixtures & Page Object Model
Custom fixtures for reusable setup and the Page Object pattern
Custom Fixtures
Create reusable test fixtures for shared setup logic
Authentication & Storage State
Reuse authentication state across tests for faster execution
Reuse Auth State
Log in once and share the session across multiple tests
Debugging & Trace Viewer
Debug failing tests with UI mode, trace viewer, and screenshots
Debugging Tools
Use UI mode, trace viewer, and headed mode to debug tests
Running Tests & CI
Run tests locally and in continuous integration pipelines
CLI Commands
Common commands for running and filtering tests
GitHub Actions CI
Run Playwright tests in a GitHub Actions workflow