PW Playwright · TSFree course: Playwright with TypeScript
Full course

Chapter 4 · Lesson 1

What Codegen is and how to start it

Difficulty: Easy
Slides
Use the arrow keys, N for notes, F for full screenOpen in a separate window ↗
Video lesson

Key points

Codegen is Playwright's recording tool. You open a browser, do actions yourself, and the tool writes the code.

npx playwright codegen https://playground.atidcollege.co.il/

Two windows open:

  • The browser window where you act, with a small toolbar.
  • Playwright Inspector, where the code appears in real time, with Record, Copy, Clear buttons and a language selector.

Save straight to a file

The -o flag saves the generated code to a file: npx playwright codegen -o tests/login.spec.ts <address>.