notes

Playwright

Playwright Commands

The Playwright CLI commands used day to day: running, reporting, debugging, codegen, and setup.

Here are the core Playwright CLI commands you'll use regularly:

Running tests

npx playwright test                  # Run all tests
npx playwright test tests/login.spec.js  # Run a specific file
npx playwright test -g "login"       # Run tests matching a title
npx playwright test --headed         # Show the browser UI
npx playwright test --debug          # Debug tests
npx playwright test --ui             # Interactive UI mode
npx playwright test --workers=1      # Run with one worker
npx playwright test --project=chromium  # Run a specific project

Reports and debugging

npx playwright show-report           # Open HTML report
npx playwright show-trace trace.zip  # View a trace
npx playwright test --trace on       # Record traces
npx playwright test --last-failed    # Rerun previously failed tests

Code generation and inspection

npx playwright codegen https://example.com  # Generate tests by interacting
npx playwright test --list                  # List tests without running

Installation and setup

npm init playwright@latest           # Set up Playwright Test
npx playwright install               # Install browser binaries
npx playwright install chromium      # Install Chromium only
npx playwright --version              # Check version

Useful options

npx playwright test --repeat-each=3  # Repeat each test 3 times
npx playwright test --retries=2      # Retry failed tests twice
npx playwright test --grep-invert="skip"  # Exclude matching test titles
npx playwright test --shard=1/3      # Run the first of 3 shards

Tip: For everyday development, remember these five:

  • npx playwright test

  • npx playwright test --headed

  • npx playwright test --ui

  • npx playwright test --debug

  • npx playwright codegen <URL>

#playwright#cli#commandscreated 12 Oct 2026

Local graph