Playwright automates Chromium, Firefox, and WebKit, and its Page API can save viewport, full-page, or element screenshots. Install the browser binaries that match your Playwright package, keep visual-test environments consistent, and use Playwright Test traces to investigate failures. This guide shows the core setup and workflows, with version-sensitive details linked to the official documentation.
How Playwright and its browsers fit together
Playwright is the automation library; the browser executables it drives are separate binaries installed through its CLI. Each Playwright version expects specific browser binaries, so updating the package can mean reinstalling browsers. These are not necessarily the Chrome or Edge builds already installed for everyday use.
The official documentation covers Chromium, Firefox, and WebKit, as well as branded browsers, device emulation, supported operating systems, and system dependencies. Check the Playwright browser documentation for the requirements applicable to your platform and installed release. Browser builds and supported details change over time, so do not assume a particular release number without checking your local package and current release notes.
Install Playwright and its browser binaries
Install the package for your project, then use the Playwright CLI to download the browser binaries expected by that installation. For a JavaScript project using npm:
#1 Best Overall
- 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.
npm init -y
npm install -D @playwright/test
npx playwright install
To install only a particular engine, pass its name to the CLI, for example npx playwright install chromium. Use the command and engine names supported by your installed version. On CI or a minimal Linux system, browser installation may also require operating-system dependencies; consult the official browser guide rather than assuming the binaries alone are sufficient.
After upgrading Playwright, rerun the browser install command if the expected binaries are missing or out of sync. This avoids a common mismatch: a new package version trying to launch binaries downloaded for an older version.
How do I take a screenshot?
Navigate a Playwright page, then call its screenshot method. This minimal Node.js example launches Chromium, captures the current viewport, and closes the browser:
const { chromium } = require('@playwright/test');
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
} finally {
await browser.close();
}
})();
The page screenshot method can save an image to a file or return image bytes for further processing. Exact options can vary by Playwright version; see the Page screenshot API for the version you use.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #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.
Capture the full scrollable page
Set fullPage: true to capture beyond the visible viewport:
await page.screenshot({ path: 'full-page.png', fullPage: true });
This is useful for a whole-page record, but it is distinct from a viewport screenshot: the resulting image can be much taller and larger. If content appears only after scrolling, loading behavior and page scripts can affect what is present at capture time.
Capture one element
Use a locator screenshot when you need a component rather than the entire page. A locator targets an element using the same locator API used in Playwright tests:
await page.getByRole('heading', { name: 'Example Domain' }).screenshot({ path: 'heading.png' });
Locator screenshots are useful for focused records and component-level checks. See the Locator screenshot API for available options.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #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.
Run browser automation across engines and devices
Playwright can automate Chromium, Firefox, and WebKit. Pick the engine that reflects the compatibility question you need to answer; a test in one engine does not establish behavior in the others. The browser binaries managed by Playwright are versioned for the installed Playwright release, while branded Chrome or Edge and device emulation are separate workflow choices described in the browser documentation.
For a simple cross-engine smoke check, launch each installed engine and visit the same URL:
const { chromium, firefox, webkit } = require('@playwright/test');
(async () => {
for (const engine of [chromium, firefox, webkit]) {
const browser = await engine.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(engine.name(), await page.title());
} finally {
await browser.close();
}
}
})();
Install all three engines with npx playwright install, or install only those your workflow needs. For device-oriented checks, use Playwright’s device emulation options; distinguish an emulated viewport and browser configuration from testing on a physical device.
Compare screenshots with Playwright Test
For visual regression testing, Playwright Test’s toHaveScreenshot() manages a reference image and compares subsequent runs against it. The first run creates the baseline; later runs compare against that saved image.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #4
- 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
const { test, expect } = require('@playwright/test');
test('landing page visual baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot();
});
Review a newly created or changed baseline rather than treating every generated image as automatically correct. Update snapshots deliberately when a UI change is intended.
Keep the rendering environment stable
Visual output can vary with host operating system, browser version, settings, hardware, power source, headless mode, and other factors. Playwright’s visual comparisons documentation recommends controlling these conditions: create and compare baselines in the same environment, including the same browser version and relevant configuration. Otherwise, a diff may reflect the environment rather than a product change.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Diagnose failures with traces
For CI test failures, Playwright’s guidance commonly records a trace on the first retry. Traces let you inspect an action timeline and DOM snapshots alongside source locations, console and network activity, metadata, and attachments. Recording traces on every test can add performance overhead, so a retry-based policy is a practical diagnostic default.
Configure tracing through Playwright Test, for example in playwright.config.js:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- 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.
const { defineConfig } = require('@playwright/test');
module.exports = defineConfig({
use: {
trace: 'on-first-retry',
},
});
After a failed run produces a trace, open it with the Trace Viewer using the command documented for your installed version, or open the trace from the Playwright HTML report. The Trace Viewer guide describes the available panels and workflow.
There is an important API boundary: low-level context.tracing captures browser operations and network activity, but it does not capture Playwright Test assertions. For fuller test-failure traces that include test-runner context, configure tracing through Playwright Test as described in the trace documentation.
Troubleshooting common problems
- Browser launch reports a missing executable: install the browser binaries for the current package with
npx playwright install, or target the required engine. If the package was upgraded, rerun the install command. - Browser launches but fails on a CI Linux host: the environment may lack required system libraries. Follow the platform-specific dependencies in the browser installation guide.
- A screenshot is blank or incomplete: confirm navigation completed and the target content is present before capturing. If content is loaded dynamically or after scrolling, wait for the relevant page condition rather than relying on an arbitrary assumption about load timing.
- Visual snapshots differ unexpectedly: align the OS, Playwright/browser version, settings, headless mode, and other rendering conditions between baseline creation and comparison. Inspect the diff before accepting a snapshot update.
- A trace lacks assertion details: a trace created with the low-level context tracing API does not include test assertions. Enable tracing through Playwright Test instead.
- Trace capture slows the suite: avoid recording every test unless needed; the CI guidance’s first-retry pattern captures evidence for failures while limiting routine overhead.
Or skip the browser setup
If you need an image or PDF from a URL without managing browser binaries, ScreenshotNeo is a screenshot API and MCP server. Its one-request API can return a screenshot or PDF:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for parameters and response details. ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up free for 1,000 screenshots a month with no card.
Frequently Asked Questions
Does Playwright take screenshots only in Chromium?
No. Playwright supports Chromium, Firefox, and WebKit; install the matching browser binaries and choose the engine your workflow needs.
Can Playwright screenshots be used as visual regression tests?
Yes. Playwright Test’s `toHaveScreenshot()` creates a reference image on its first run and compares later runs against it.
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.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches

