LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

playwright

Cross-browser automation and testing framework

TLDR

Install browsers
$ npx playwright install
copy
Run tests
$ npx playwright test
copy
Run specific test
$ npx playwright test [test.spec.ts]
copy
Run with UI mode
$ npx playwright test --ui
copy
Generate code
$ npx playwright codegen [url]
copy

SYNOPSIS

playwright command [options]

DESCRIPTION

Playwright is a framework for browser automation and testing. It supports Chromium, Firefox, and WebKit with a unified API for cross-browser testing.

PARAMETERS

install [browser]

Install browsers (chromium, firefox, webkit) and dependencies.
install-deps
Install OS-level dependencies required by browsers (Linux).
test [files]
Run Playwright tests.
codegen [url]
Record user actions and generate test code.
show-report [dir]
Open the HTML report in a browser.
open [url]
Open a page in Playwright inspector.
--ui
Launch interactive UI mode for running and debugging tests.
--debug
Run tests in debug mode with Playwright Inspector.
--headed
Run browsers in headed mode (visible window).
--project NAME
Run only the given project (browser) from the config.
--workers N
Number of parallel test worker processes.
--reporter NAME
Reporter to use (list, dot, line, html, json, junit).
--grep PATTERN
Only run tests matching the regex pattern.
--retries N
Number of times to retry failing tests.

EXAMPLES

$ # Setup new project
npm init playwright@latest

# Run all tests
npx playwright test

# Run with specific browser
npx playwright test --project=firefox

# Debug failing test
npx playwright test --debug

# Generate code by recording
npx playwright codegen example.com

# Show HTML report
npx playwright show-report
copy

CONFIGURATION

playwright.config.ts or playwright.config.js

Project configuration file defining browsers, test directories, timeouts, and reporter settings.
PLAYWRIGHT_BROWSERS_PATH
Environment variable to override the browser binary download location.

TEST EXAMPLE

$ import { test, expect } from '@playwright/test';

test('basic test', async ({ page }) => {
  await page.goto('https://example.com');
  await expect(page).toHaveTitle(/Example/);
});
copy

CAVEATS

Requires Node.js. Browser binaries are large. CI may need special setup.

HISTORY

Playwright was developed by Microsoft, created by the team behind Puppeteer, released in 2020.

SEE ALSO

puppeteer(1), node(1), npx(1)

Copied to clipboard
Kai