Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

Playwright Framework: Getting Started with Browser Testing

A practical npm-first guide to Playwright Test: installation, browser setup, a first end-to-end test, reliable locators, local debugging, and CI.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To get started with browser testing, install Playwright Test, let it install its matching browsers, then write a test that interacts with the page through user-facing locators and checks the result with an awaited assertion. For an npm project, begin with npm init playwright@latest. This guide takes you from setup through your first test, local debugging, and a basic CI workflow.

What Playwright Test includes

Playwright Test is Playwright’s end-to-end testing framework. It combines a test runner, assertions, fixtures for setting up tests, isolation, parallel execution, and debugging tools. A test uses a browser page to perform actions, then checks that the application reached the expected state.

The examples below use npm and TypeScript, as in the official starter. Package, browser, and runtime support can change, so consult the current Playwright installation and CI documentation before choosing version-specific requirements.

Install Playwright in an npm project

  1. In your project directory, run npm init playwright@latest.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    #1 Best Overall
    Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
    • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
    • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
    • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
    • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
    • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
  2. Follow the prompts to initialize a new project or add Playwright to an existing one. Choose JavaScript or TypeScript as appropriate, and whether to add a CI workflow if prompted.

  3. Keep the generated configuration and example test initially. They give you a working reference for your project’s setup.

The setup command installs the Playwright Test package and can download browser binaries. If you need a different package manager, use the equivalent command in Playwright’s installation guide.

Install the browsers Playwright needs

Playwright uses browser binaries matched to the installed Playwright version; it does not simply drive whatever browser happens to be installed on the machine. Install the default browser set with:

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

npx playwright install

If you update the Playwright package, the required browser builds may change too. Run the install command again if a browser is missing or does not match the package.

Which browsers does Playwright support?

The core engines are Chromium, Firefox, and WebKit. Testing across them can reveal engine-specific behavior. Playwright also documents branded Chrome and Edge channels and device emulation for narrower compatibility needs. More browser projects can mean more execution time and configuration; there is no universal requirement that every team run every combination.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Write a meaningful first test

This test opens the Playwright site, follows its user-facing “Get started” link, and verifies that the installation page’s heading appears:

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

test('get started link opens installation page', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await page.getByRole('link', { name: 'Get started' }).click();
  await expect(
    page.getByRole('heading', { name: 'Installation' })
  ).toBeVisible();
});

test declares a test case. The page argument is a fixture supplied by the runner. goto navigates to the page; getByRole finds the link by its accessible role and name; click interacts with it; and expect(...).toBeVisible() checks the result. The official writing-tests guide describes the pattern as actions followed by assertions about the resulting state.

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

Save the test in the test directory created by the starter, or in a path matched by your Playwright configuration. To test your own application, replace the example URL and choose an interaction and outcome that represent a real user task.

Choose locators and assertions that wait for the page

Prefer locators tied to the interface

Use locators that describe how a person encounters the control: role and accessible name, label, visible text, or placeholder. They make a test’s intent easier to read and can expose accessibility problems when an expected name is absent. Use a test ID when your team deliberately defines it as a stable testing contract.

Locators are resolved when an action or assertion uses them, rather than binding permanently to an element at declaration time. Playwright can therefore retry resolution as the page changes.

Use web-first assertions, not routine fixed sleeps

Await assertions such as await expect(locator).toBeVisible() or await expect(page).toHaveTitle(/Playwright/). Web-first assertions wait for the expected condition, and locator actions wait for actionability. A fixed delay such as waitForTimeout usually makes a test slower without establishing that the page is actually ready; use a condition that reflects the expected state instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Understand test isolation

The built-in page fixture is provided for a test run and is backed by a browser context. A context behaves like a fresh browser profile, so a test should not assume another test left it cookies, storage, or page state. This isolation helps tests run independently. Start with built-in fixtures; add custom fixtures when repeated setup or shared test-specific behavior makes them worthwhile.

Run tests and debug failures locally

Routine run

Run the configured suite from the project directory:

npx playwright test

Tests run headlessly by default, without opening a visible browser window.

See the browser or use interactive inspection

  • Run npx playwright test --headed to watch the browser while tests execute.

    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 npx playwright test --ui to select and rerun tests interactively and inspect their execution.

  • After a run, use npx playwright show-report to open the HTML report.

    Rank #4
    Sale
    UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
    • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
    • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
    • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
    • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
    • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

When a test fails, first distinguish whether the browser did not launch, a locator could not find or act on the intended element, or an assertion never observed the expected result. Headed mode and UI Mode help inspect those different failure points.

Add a basic CI workflow

A CI job needs the project dependencies and Playwright browser binaries before it runs tests. For an npm project, the sequence is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Check out the code and set up a Node.js runtime supported by the current Playwright release.

  2. Install the locked dependencies with npm ci.

  3. Install browsers with npx playwright install. On a Linux runner that also needs system packages, use npx playwright install --with-deps.

  4. Run npx playwright test.

For reproducibility, the Playwright CI guide recommends one worker as the stable default in CI. Set workers: 1 in playwright.config.ts if you want to apply that default explicitly. Teams with suitable infrastructure can consider more workers or sharding. Browser caching is not always worthwhile, especially when Linux system dependencies still need installation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common setup and test failures

Or skip the browser setup

ScreenshotNeo is a screenshot API, not a replacement for Playwright’s interactions, assertions, or end-to-end test runner. If your task is to capture a page image or PDF rather than verify behavior, its one-request API avoids managing a browser locally. See the ScreenshotNeo API documentation.

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

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers identifying the page verdict and billing status. Its MCP server offers screenshot, page-info, and PDF tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card required.

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.

Frequently Asked Questions

Can I use Playwright for unit tests?

This guide covers Playwright Test’s browser-based end-to-end workflow; it does not describe a unit-testing setup.

Does Playwright run tests headlessly by default?

Yes. Use the headed or UI options described above when you need to see or interactively inspect a browser run.

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
PC Slower Than It Used to Be?Free scan - under a minute

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.