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
-
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.
-
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.
-
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:
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →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
- 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.
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.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsRank #3
- 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 --headedto 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 --uito select and rerun tests interactively and inspect their execution. -
After a run, use
npx playwright show-reportto open the HTML report.Rank #4
SaleUGREEN 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:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →-
Check out the code and set up a Node.js runtime supported by the current Playwright release.
-
Install the locked dependencies with
npm ci. -
Install browsers with
npx playwright install. On a Linux runner that also needs system packages, usenpx playwright install --with-deps. -
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.
Common setup and test failures
-
Browser executable is missing: Install the browsers for the installed package with
npx playwright install. If dependencies were updated, install again so the browser binaries match.PerformancePC Slower Than It Used to Be?DriversOutdated Drivers Are Slowing You DownPerformanceWindows Errors? Fix Them Before They SpreadSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
-
Browser fails to launch on Linux CI: The runner may lack operating-system packages. Try
npx playwright install --with-depsin the CI setup stage. -
Locator finds no element: Check that navigation reached the intended page, then verify the element’s role, accessible name, label, text, or placeholder against the rendered interface. Prefer a meaningful locator over a brittle positional selector.
-
Click does not proceed: The target may not be actionable yet or may be obscured. Use the locator action’s normal waiting behavior and inspect the page in headed mode or UI Mode rather than adding an arbitrary sleep.
-
Assertion times out: Confirm the test’s expected result is correct and that the preceding action actually caused it. If the app is asynchronous, assert on the eventual user-visible state rather than an intermediate state.
Recommended: Update Every Outdated Driver on Your PC in One Scan - Free →Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Recommended: Crashes or Glitches? A Free Driver Scan Usually Finds the Culprit →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
A test passes alone but fails in the suite: Look for an assumption about state created by another test. Each test should establish its own required state because page fixtures are isolated.
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.
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.
Quick Recap
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.




