Skip to main content

UI Automation with Playwright

A practical guide to end-to-end UI testing with Playwright: from install and recording through page objects, authentication and CI. Written in the same order I use on a project. New to automation? Read Automation first for the mental model.

Important: This track is in progress. Every code sample lives in playwright/sample/ and the status table below says which pages have been run end to end on Playwright 1.63 and which have not. Pages marked "Not yet validated" follow the official docs but have not been exercised on a real project yet.

Status​

PageStatusNotes
1. Install ToolsValidatedInit command and first run executed on macOS
2. Understand What to AutomateReviewedConceptual page, nothing to run
3. Playwright ConceptsReviewedConceptual page, code samples come from the validated sample project
4. Recording with CodegenPartly validatedCLI flags checked against 1.63. Recorder session and VS Code flow not yet captured
5. Locators and AssertionsValidatedAll examples run in the sample project
6. Test Structure and Page ObjectsValidatedPage objects, fixtures and data file run in the sample project
7. DebugPartly validatedTrace recording, trace CLI and run flags verified. UI mode and Inspector not yet captured
8. Configuration and RunningValidatedConfig and commands run in the sample project
9. Authentication and StateValidatedSetup project and storageState run in the sample project
10. Running in CINot yet validatedWorkflow matches the official docs and the generated file. Not yet run on this repo's CI

Basics​

#TopicDescription
1Install ToolsNode, VS Code extension, Playwright project, browsers
2Understand What to AutomateWhich flows deserve a UI test
3Playwright ConceptsTests, locators, actions, assertions, fixtures, projects
4Recording with CodegenRecord a flow, then clean it up
5Locators and AssertionsFinding elements that survive redesigns, checks that retry
6Test Structure and Page ObjectsNaming, hooks, page objects, fixtures, test data
7DebugUI mode, trace viewer, inspector, common failures

Running​

#TopicDescription
8Configuration and RunningThe config file, projects, parallelism, reports
9Authentication and StateLog in once, reuse the session
10Running in CIGitHub Actions, artifacts, sharding, flaky policy

Appendix​

TopicDescription
Future / To ExploreAPI testing, mocking, visual and aria snapshots, agents

The Sample Project​

Everything shown in these pages runs from playwright/sample/ in the repository:

cd playwright/sample
npm ci
npx playwright install chromium
npx playwright test

Nine tests against two public demo apps: Playwright's TodoMVC demo and saucedemo.com.