Chapter 50: Codegen and Inspector
Automation learning lab
Playwright Automation
Self Study Guide
Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.
Codegen and Inspector
Codegen records actions in a browser and suggests locators and code. The Inspector helps step through a test and inspect locator matches. Generated code is a starting point; review it and add assertions that reflect the actual requirement.
How it works
Step-by-step walkthrough
- Launch Codegen on the demo
- Record an interaction
- Review and refine the generated script
Example
npx playwright codegen https://demo.playwright.dev/todomvc/
npx playwright test --debugNever record real passwords into generated test scripts.
Screenshot walkthrough

✎ Your practice task
Record adding one todo and add a visible-text assertion.
Knowledge check
Should generated code be reviewed before committing?
🌐 Continue learning
60-chapter learning path
Start at chapter 1, or choose any topic. Your progress is tracked separately for each chapter.
JavaScript fundamentals
TypeScript fundamentals
Playwright • setup & locators
Playwright • interactions & assertions
Playwright • framework & debugging
Playwright • real-world automation
Interactive practice lab
Try the controls below and observe the corresponding Playwright locator instructions. This browser demo does not execute Node.js or Playwright Test; copy the code to your local Playwright project to automate it.
Task manager demo
Suggested automation
Actions on the demo update these examples. In your local test use a page that contains the same controls.
Download a standalone lab page, then serve it locally (for example with Python's http.server). Navigate to it in a Playwright test.