What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run Playwright’s test suite from a project directory with npx playwright test. It runs headless by default and uses the browser projects in your playwright.config.* file. To run a particular test, pass a file, directory, line number, or title filter; use --headed, --ui, or --debug when you need to see or inspect the browser.

Install Playwright and its browsers

Use the package manager already used by your project. For an npm project, install the test package as a development dependency and download the browser binaries separately:

npm install -D @playwright/test@latest
npx playwright install

The install command downloads the browsers Playwright needs to run tests. On Linux environments where required operating-system packages are missing, install those dependencies too:

npx playwright install --with-deps

You can install a specific browser instead of all supported browser binaries, for example npx playwright install chromium. To check which Playwright version the project resolves, run npx playwright --version. After updating Playwright, rerun the browser install command if the updated version requires different browser binaries; the official browser guide covers this relationship at Playwright browser installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run tests from the terminal

Run the configured suite

From the project root, run:

npx playwright test

This invokes the Playwright test runner for the projects and files selected by the project configuration. Without a visible-browser option, execution is headless. A successful run prints the test outcomes in the terminal; failures include diagnostic output that you can investigate or inspect in a report or trace.

Choose a file, directory, line, or test title

Pass a test-file path or directory to narrow the run. To target a test near a particular line, append a colon and line number to the file path. To select by title, use -g followed by a regular-expression match:

npx playwright test tests/todo-page.spec.ts
npx playwright test tests/landing-page/
npx playwright test my-spec.ts:42
npx playwright test -g "add a todo item"

Non-option arguments are regular expressions matched against full test-file paths. Quote arguments that contain shell metacharacters or characters your shell might interpret, so the shell passes the intended filter to Playwright.

Select browser projects

If your configuration defines projects such as Chromium, Firefox, or WebKit, select one by its configured project name:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx playwright test --project=chromium

This limits the run to that project; it does not install a browser binary. If the project name differs from chromium, use the name in playwright.config.*.

Choose how the run behaves

Show the browser or use an interactive mode

  • --headed opens visible browser windows instead of running headless.
  • --ui starts Playwright UI Mode for interactive test selection and inspection.
  • --debug launches the Playwright Inspector in a headed, single-worker debugging setup with an unlimited timeout and stop-after-one-failure behavior.

For example, to debug one test around line 10:

npx playwright test tests/example.spec.ts:10 --debug

Use headed mode when watching the page is enough; use UI Mode to interactively explore tests and results; use --debug when stepping through a focused failure is more useful than a normal run.

Control parallelism, retries, and run size

Playwright normally runs tests in parallel according to configuration. For a simpler local reproduction, set one worker:

npx playwright test --workers=1

Other useful controls include --retries to retry failed tests, --timeout to adjust the test timeout, --max-failures to stop after a chosen number of failures, --repeat-each to repeat tests, --shard to divide a suite across runs, and --only-changed to focus on tests affected by changes. These options address different needs: retries can help reveal intermittent failures but may mask instability if treated as a fix; workers trade faster completion for more simultaneous browser activity; sharding is useful when a suite is distributed across jobs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select terminal output

Use --reporter to choose output suited to the environment. Available documented examples include list, dot, line, json, junit, html, and blob:

npx playwright test --reporter=list
npx playwright test --reporter=junit

Use a concise reporter for a noisy suite, or a machine-readable format such as JSON or JUnit when another tool consumes the results. Check npx playwright --help for the installed version’s complete options and any configured reporter details.

Open reports and traces after a run

View the HTML report

Open the default report after a test run with:

npx playwright show-report

If the report is in a particular directory, supply it. You can also choose a port:

npx playwright show-report playwright-report/ --port 8080

The HTML report lets you filter passed, failed, skipped, and flaky tests and inspect step details. Generate or configure an HTML reporter for the run if you need a report to inspect.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect a trace

When a test has trace data, open its archive with:

npx playwright show-trace trace.zip

The trace viewer is useful for examining what happened during a browser session. Configure tracing for the test run when you want trace artifacts; the command opens an existing trace and does not create one retroactively. The CLI also provides host and port options for show-trace, and merge-reports can combine blob reports. Run npx playwright --help to see the syntax for the installed version.

Record starter code with Codegen

Codegen opens a browser and Playwright Inspector, records interactions, and generates starter code. A few common invocations are:

npx playwright codegen https://playwright.dev
npx playwright codegen --target=python
npx playwright codegen --output=tests/generated.spec.ts https://example.com

Use the target option to generate code for a chosen language, or the output option to write generated code to a file. The guide also documents browser selection, test-id attributes, viewport, timezone, geolocation, language, and persistent user-data options: Playwright Codegen. Treat the output as a starting point: review locators and assertions, then add checks that prove the intended behavior rather than merely replaying clicks.

Quick command reference

Goal Command
Run all configured tests npx playwright test
Run one file or directory npx playwright test tests/todo-page.spec.ts
npx playwright test tests/landing-page/
Target a line or title npx playwright test my-spec.ts:42
npx playwright test -g "add a todo item"
Use a project or visible browser npx playwright test --project=chromium
npx playwright test --headed
Debug a focused test npx playwright test tests/example.spec.ts:10 --debug
Open results npx playwright show-report
npx playwright show-trace trace.zip
Record interactions npx playwright codegen https://playwright.dev
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common command-line problems

Command not found or wrong Playwright version

Run commands from the project directory after installing @playwright/test. With npm, npx resolves the project’s package. Check the resolved version with npx playwright --version and consult npx playwright --help for the options supported by that version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Browser executable is missing

Install browser binaries with npx playwright install. If the machine lacks operating-system libraries, use npx playwright install --with-deps in an environment where dependency installation is permitted. Following a Playwright update, rerun the browser installer if binaries are out of sync.

A test filter selects nothing or too much

Confirm the path relative to the current project and remember that non-option arguments are regular expressions matched against full test-file paths. Quote patterns so the shell does not expand them. For title selection, use -g and a distinctive title fragment; for a line target, use the test file followed by :line.

A test behaves differently in parallel

Reproduce serially with --workers=1. If serial execution changes the outcome, investigate shared state, test-data collisions, or assumptions about execution order rather than assuming that a retry has fixed the underlying issue.

Report or trace does not open

show-report expects an existing report directory, while show-trace expects trace data such as an archive. Run tests with the appropriate reporter or tracing configuration first, then pass the correct output path. If you are unsure of accepted path or port options, check npx playwright --help.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Debug mode is too slow or stops early

--debug intentionally uses one worker, an unlimited timeout, headed mode, and stops after one failure. That is helpful for inspecting a failure but is not representative of a normal parallel test run. Remove --debug to restore ordinary execution behavior.

Or skip the browser setup

Playwright is the right choice when you need to run and assert on your own browser tests. If you only need a screenshot of a web page, ScreenshotNeo offers a one-request API instead of setting up a browser runner. Its consent-banner handling accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. It also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.

cURL example; see the ScreenshotNeo API documentation for request options:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo returns PNG, JPEG, WebP, or PDF. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month, no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can I run a single Playwright test without running the whole suite?

Yes. Pass its file path, line target, or a title filter with -g to limit the run.

Does show-trace create a trace?

No. It opens trace data created by a test run; configure tracing before execution when you need an archive to inspect.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.