Before the workshop โ€” get Playwright running

Land one green Playwright test on your laptop today, plus the Playwright CLI we'll need for the AI blocks. Day-of we go straight to the fun stuff.

Hello! ๐Ÿ‘‹

Welcome โ€” really glad you're joining us. The workshop is one full day of hands-on Playwright, including five blocks on AI-assisted testing.

We'll spend the day writing tests against the ecommerce site you're on right now.

This prep lesson takes about 20 minutes. Please run through it before the workshop. It installs browsers, pulls dependencies, and gets the CLI ready for the AI blocks.

Note

If anything in this prep doesn't work, you don't have to figure it out alone. Reach out via email, screenshot the error, and we'll sort it before day one.


What you'll need

A laptop with:

  • Node.js โ€” latest 20.x, 22.x, or 24.x (Playwright's official requirements)
  • A code editor โ€” VS Code is what I'll use in demos, but anything else works, too
  • A terminal
  • ~1.5 GB free disk space โ€” Playwright bundles Chromium, Firefox, and WebKit

Check your Node.js version

node --version
v22.11.0

Anything v20.x or newer is fine. If you're on v18 or older, install a current LTS via nodejs.org or your version manager of choice (nvm, fnm, volta, โ€ฆ).

Warning

Windows users: Playwright supports Windows 11+, Windows Server 2019+, or WSL. macOS users need macOS 14 (Sonoma) or newer. Linux users: Debian 12 or 13, Ubuntu 22.04, or Ubuntu 24.04.


Install Playwright

Step 1 โ€” Create a fresh Playwright project

Pick (or create) an empty directory and run:

$ mkdir pwt-workshop && cd pwt-workshop
$ npm init playwright@latest

You'll get a few prompts. Pick these answers:

Getting started with writing end-to-end tests with Playwright:
Initializing project in '.'
โœ” Do you want to use TypeScript or JavaScript? ยท TypeScript
โœ” Where to put your end-to-end tests? ยท tests
โœ” Add a GitHub Actions workflow? (y/N) ยท false
โœ” Install Playwright browsers (can be done manually via 'npx playwright install')? (Y/n) ยท true

This downloads Chromium, Firefox, and WebKit (the bundled, version-pinned builds Playwright tests against).

When it finishes, you should see a fresh project with:

.
โ”œโ”€โ”€ node_modules/
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ example.spec.ts
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ package-lock.json
โ””โ”€โ”€ playwright.config.ts
Note

We're using TypeScript throughout the workshop. Don't worry if you're not fluent at wrangling all the types. Often, you don't need to provide types to make your Playwright tests work.

Step 2 โ€” Confirm the version

npx playwright --version
Version 1.59.1

Anything 1.59.x or newer is what we need. If you're on an older version, re-run the init in a fresh directory.

Step 3 โ€” Run the example tests

Playwright ships an example.spec.ts in tests/. Run it with the default test command:

npx playwright test
Running 6 tests using 5 workers
  6 passed (3.6s)

To open last HTML report run:

  npx playwright show-report

Six green tests across three browsers โ€” that's the baseline. If you see this, your environment is ready. ๐ŸŽ‰

If something fails, the most common causes are:

  • Browser download incomplete โ€” re-run npx playwright install
  • Old Node.js โ€” check node --version (need 20.x or newer)

Step 4 โ€” See what the tests are doing

Headless tests are fast but invisible. Open a real browser to watch them run:

$ npx playwright test --headed

Then try the UI mode โ€” this is the tool we'll live in during the workshop:

$ npx playwright test --ui

UI mode gives you time-travel debugging, a locator picker, network inspection, and watch mode. It's the single best reason to use Playwright โ€” we'll spend real time here from the very first lesson.

Using Playwright with AI

Don't have a coding agent yet? Claude Code is the one we'll use in demos. The free tier might work for the workshop, but you'll likely hit its token limits quickly. Sign up for one of the smaller paid tiers if possible.

Install the Playwright CLI

We'll use @playwright/cli later in the workshop to have an AI coding agent drive the browser and write tests for us. It's published by the Playwright team and exposes Playwright as a token-efficient CLI surface that agents (Claude Code, Copilot, โ€ฆ) can call as tools.

Install it globally so the playwright-cli binary is on your PATH:

$ npm install -g @playwright/cli@latest
Note

We need @playwright/cli 0.1.11 or newer for the AI lessons. Check with playwright-cli --version and re-run the install above if you're on an older build.

Confirm it's on your PATH:

playwright-cli --help
playwright-cli - run playwright mcp commands from terminal

Usage: playwright-cli <command> [args] [options]
Usage: playwright-cli -s=<session> <command> [args] [options]

Core:
  open [url]                  open the browser
  attach [name]               attach to a running playwright browser
  close                       close the browser

...

Then install the agent skills (a small set of instructions your coding agent reads to understand how to use the CLI):

playwright-cli install --skills
โœ… Workspace initialized at `/private/tmp/pwt-dry-run`.
โœ… Skills installed to `.claude/skills/playwright-cli`.
โœ… Found chrome, will use it as the default browser.

Quick smoke test โ€” this should pop a headed browser and print the following:

playwright-cli open https://playwright.dev --headed
### Browser `default` opened with pid 98274.
### Ran Playwright code
```js
await page.goto('https://playwright.dev');
```

### Page
- Page URL: https://playwright.dev/
- Page Title: Fast and reliable end-to-end testing for modern web apps | Playwright

### Snapshot
- [Snapshot](.playwright-cli/page-2026-05-02T12-39-03-711Z.yml)
Note

@playwright/cli is different from npx playwright (the one that comes with @playwright/test). npx playwright runs your test suite. playwright-cli is a thin, scriptable surface for coding agents. We'll use both during the workshop.


Day-of checklist

On workshop day, please bring:

  • Power adapter โ€” a full day of testing drains a battery
  • Your laptop with the prep above completed
  • An open mind โ€” if you've used Cypress / Selenium / Puppeteer, some habits will serve you and some won't
Hands on

You're done!

Run through this final check. When every item below is true on your laptop, mark it done โ€” you're ready for May 6.

Exercise 1 of 1

Confirm everything is set up

  • Node.js 20.x or newer is installed (node --version).
  • A fresh pwt-workshop project was created with npm init playwright@latest.
  • Playwright is version 1.59 or newer (npx playwright --version).
  • All 6 example tests pass (npx playwright test).
  • I've opened UI mode at least once (npx playwright test --ui).
  • @playwright/cli is installed globally and playwright-cli --help works.
  • playwright-cli install --skills ran successfully.

See you on workshop day. ๐ŸŽญ