Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk6 min

Playwright: Getting Started with the Browser Automation Tool

Initialize Playwright Test, install matching browsers, write a test with a role-based locator and web-first assertions, then run and debug it locally.

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.

To get started with Playwright, initialize Playwright Test in a JavaScript or TypeScript project, install the browser binaries for your configured projects, write a test with an accessible locator and an observable assertion, then run it with npx playwright test. Playwright Test supplies the runner, assertions, isolated browser contexts, parallel execution, and debugging tools for end-to-end tests.

What Playwright is—and what you need

Playwright Test is an end-to-end testing framework for modern web applications. It can automate Chromium, Firefox, and WebKit on Windows, Linux, and macOS, locally or in CI. It supports headless and headed runs, plus mobile-device emulation for Chrome on Android and Mobile Safari. See the installation guide and verify its requirements against the stable documentation and your environment: that linked page is explicitly the Next documentation path, and its listed runtime and operating-system requirements may change.

The workflow below assumes a JavaScript or TypeScript project and Node.js. Use the package manager already used by your project so dependencies and lockfiles remain consistent. For a new project, the initializer can create a starter test directory and configuration; for an existing project, review what it adds before committing the changes.

Initialize Playwright Test

Run one of the following from your project directory:

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.
  • npm init playwright@latest
  • yarn create playwright
  • pnpm create playwright

The setup prompts you to choose JavaScript or TypeScript, a test directory, whether to add a GitHub Actions workflow, and whether to install browsers. The initializer can also be run later; the setup guide says it does not overwrite existing tests. Inspect the generated playwright.config.ts, package manifest and lockfile, and example test. The config is where browser projects, timeouts, retries, and reporters are centralized.

Install the browser binaries for your projects

Playwright’s browser binaries are tied to its release. Install the browsers required by your configured projects, and repeat the install after updating Playwright if it reports that a browser is missing. The browser guide documents these commands:

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
  • npx playwright install installs the default browser set.
  • npx playwright install chromium installs Chromium only.
  • On Linux, npx playwright install --with-deps can install browsers and required system dependencies, or use npx playwright install-deps for dependencies.

Browser files use disk space and are stored in OS-specific caches by default; exact sizes vary by release. The browser guide also covers listing and uninstalling browser installations, shared or hermetic browser locations, proxy and custom-download-host environment variables, and supplying a trusted custom root certificate when needed. Do not disable certificate checks to work around a download problem.

Playwright browsers versus branded Chrome and Edge

The default Chromium project uses Playwright’s Chromium build. Branded Google Chrome and Microsoft Edge are separate channels and are not installed by default. If you specifically need to test those distributions, install the relevant browser and configure the matching channel in your project. Otherwise, the docs recommend the default latest Chromium configuration for most use cases.

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

Choose a browser matrix

The default setup can include Chromium, Firefox, and WebKit. Projects let you express which engines or browser channels to test; use the full configured matrix for broad coverage or select one project while developing. The right matrix depends on the browsers your users need, your operating systems, and whether mobile emulation is relevant—not simply on whether a browser can launch.

Write a first test with an observable result

Create a test file in the configured test directory, such as tests/getting-started.spec.ts. This example checks both the page title and a visible heading after following a link:

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
import { test, expect } from '@playwright/test';

test('navigation reaches the installation guide', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await expect(page).toHaveTitle(/Playwright/);

  await page.getByRole('link', { name: 'Get started' }).click();
  await expect(
    page.getByRole('heading', { name: /installation/i })
  ).toBeVisible();
});

Use a URL and link name that match the site version you intend to test; the example illustrates the test pattern, not a guarantee that a site’s navigation labels never change. The page fixture gives the test a page to control. Playwright isolates tests with separate browser contexts, so each test can start without sharing browser state with another.

Prefer locators that describe the element the way a user or assistive technology identifies it, such as getByRole with a name. Positional selectors can break when page structure changes. Playwright waits for actionability conditions before actions and its web-first assertions wait for the expected state. A fixed sleep is usually a weaker substitute: it can make tests slow and still fail under variable load. This action-then-outcome style checks more than whether a browser opened; it verifies what the user-visible page did. See Writing tests for locator and assertion details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Run the test and inspect the result

From the project directory, run:

npx playwright test

Playwright runs tests headlessly by default against configured projects and reports results in the terminal. The running and debugging guide documents these useful variants:

  • npx playwright test --project=chromium runs only the named configured project. Replace chromium with a project name from your config.
  • npx playwright test --headed opens browser windows so you can watch interactions.
  • npx playwright test --ui opens UI mode for interactive execution, step inspection, watch mode, locator picking, and trace integration.
  • npx playwright show-report opens the HTML test report after a run has produced one.

Use the CLI for a quick pass, headed mode when the interaction itself is hard to understand, and UI mode or traces when you need to inspect the sequence of actions and failure context.

Optional: use the VS Code extension

The Playwright VS Code extension adds Test Explorer controls, individual test runs and debugging with breakpoints, a live browser, test recording, locator picking, and trace viewing. It is an editor convenience; the command-line setup and run flow are sufficient to begin.

Troubleshoot common setup and run failures

  • Missing browser executable after a package update: install binaries matching the installed Playwright release with npx playwright install, or install just the configured engine, such as npx playwright install chromium.
  • Linux launch failure or missing system library: install the required operating-system dependencies with npx playwright install --with-deps or npx playwright install-deps. Follow the browser guide for supported platform details.
  • Chrome or Edge channel cannot be found: branded browsers are not included by default. Install the desired channel and ensure the project uses the corresponding channel configuration, or use Playwright’s bundled Chromium instead.
  • Browser download fails behind a proxy or artifact mirror: consult the browser guide’s proxy and custom-download-host environment-variable instructions. If your environment uses a private certificate authority, supply its trusted root certificate rather than disabling certificate verification.
  • A test fails intermittently around a click or page transition: check that the locator identifies the intended element and that the assertion describes the expected resulting state. Prefer a locator-based action and web-first assertion over arbitrary delay.
  • The terminal failure lacks enough context: rerun with --headed to watch the browser, or use --ui to inspect steps and traces. The HTML report is available with npx playwright show-report when a report has been generated.

Or skip the browser setup

Playwright is for interactive browser tests. If your task is to save a page as a screenshot or PDF rather than test browser behavior, ScreenshotNeo offers a one-request screenshot API. For other Playwright scenarios, use the setup above; a screenshot endpoint is not a replacement for an end-to-end test.

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

Example cURL request, with API documentation:

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

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. It also provides an MCP server with screenshot, page-info, and PDF-capture tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.