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 →Use page.screenshot() to capture a Playwright page. Pass path to write an image file, or omit it and receive the image as a buffer. Add fullPage: true for the complete scrollable document, use a locator for one element, and use options such as type, quality, scale, masks, and injected styles to make captures deterministic.
Basic Playwright screenshot syntax
Install Playwright and its browser binaries, then call the Page API after navigation:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
await browser.close();
})();
This is the documented pattern for Chromium; Playwright also supports Firefox and WebKit. page.screenshot() returns a buffer. When path is supplied, the file is written there. A relative path is resolved from the process’s current working directory. With a path, Playwright infers the format from the extension; PNG is the documented default.
Save or process the returned buffer
const image = await page.screenshot();
console.log(`Captured ${image.length} bytes`);
// Send image to storage, an HTTP response, or another image processor.
Do not close the browser until you have finished using the buffer. Create the destination directory yourself when your script writes to a nested path; Playwright does not make arbitrary parent directories for you.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors#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.
Choose what to capture
Current viewport
Omit fullPage to capture only the viewport currently visible to the page:
await page.screenshot({ path: 'viewport.png' });
The viewport comes from the browser context or page options. Set it before navigation when consistent dimensions matter:
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
const page = await context.newPage();
Full scrollable page
Set fullPage: true to capture the page’s full scrollable area rather than only the visible viewport:
await page.screenshot({ path: 'full-page.png', fullPage: true });
Long pages can create very large images. Lazy-loaded content may not appear unless scrolling triggers it; wait for the relevant content or use an application-specific readiness signal before capturing.
Rectangular clip
Use clip for a page-coordinate rectangle. The object requires x, y, width, and height:
await page.screenshot({
path: 'header-region.png',
clip: { x: 0, y: 0, width: 1200, height: 240 }
});
Clip coordinates describe the page, not a selector. For a moving or responsive component, a locator screenshot is usually less fragile.
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.
One element with a locator
Prefer locator screenshots over the discouraged ElementHandle.screenshot() API:
await page.getByRole('button', { name: 'Sign in' })
.screenshot({ path: 'sign-in-button.png' });
Locator capture performs actionability checks and scrolls the target into view. A covered element is not magically uncovered: an overlay can hide it in the resulting image. For a scrollable container, only the content at that container’s current scroll position is visible.
const card = page.locator('[data-testid="pricing-card"]');
await card.screenshot({ path: 'pricing-card.png' });
If the locator matches multiple nodes, strictness errors can occur. Narrow it with a role, label, test id, or .first() only when selecting the first match is intentional.
Output format, scale, and quality
The screenshot options let you trade fidelity, file size, and portability:
| Option | Use | Important behavior |
|---|---|---|
type |
Choose png, jpeg, or webp where supported by the installed Playwright version. |
When saving by path, the extension normally determines the type. |
quality |
Control lossy image quality. | Relevant to JPEG and WebP; PNG is lossless and does not use this setting. |
scale |
Choose css or device pixel scaling. |
css keeps output near CSS dimensions; device preserves device-pixel density and can produce larger files. |
omitBackground |
Keep transparent areas transparent. | Useful for PNG overlays and assets; page backgrounds must actually be transparent. |
await page.screenshot({
path: 'hero.webp',
type: 'webp',
quality: 82,
scale: 'css'
});
Check the version of Playwright installed in your project before relying on a newer option, because supported formats and options can vary by release.
Make screenshots stable
Wait for the state you need
page.goto() reaching its default load condition does not guarantee that client-rendered text, images, or fonts are ready. Wait for a selector, an assertion, or an application event:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree 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.
await page.goto('https://example.com/dashboard');
await page.locator('[data-testid="dashboard"]').waitFor();
await page.screenshot({ path: 'dashboard.png' });
For a known delay, page.waitForTimeout() is simple but brittle. Prefer a condition that represents readiness, such as visible text or a network response.
Disable animation and blinking content
Animations can change pixels between runs. In visual tests, use screenshot assertions’ animation controls, or inject CSS before capture:
await page.addStyleTag({ content: `
*, *::before, *::after {
animation: none !important;
transition: none !important;
caret-color: transparent !important;
}
` });
await page.screenshot({ path: 'stable.png' });
Freeze clocks or mock random data in the application when timestamps, rotating banners, or generated identifiers are part of the image. Keep fonts and browser versions consistent across machines to avoid layout drift.
Mask changing regions
Playwright Test screenshot assertions can mask locators that contain timestamps, avatars, advertisements, or other intentionally variable content. A mask color can make the changed region obvious while keeping the comparison deterministic. If you are using the raw Page API, hide or replace those nodes with injected CSS before capturing.
Inject a screenshot-only style
Use a stylesheet added immediately before the shot to hide cookie prompts, caret indicators, or debug controls without changing production code. Remove the style or create a fresh page for subsequent interactions if the page must return to its normal appearance.
Screenshot assertions in Playwright Test
For visual regression tests, use expect(page).toHaveScreenshot() rather than manually comparing files:
import { test, expect } from '@playwright/test';
test('home page visual baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('home.png', {
fullPage: true,
animations: 'disabled'
});
});
On the first run, Playwright creates a baseline in the configured snapshot directory. Later runs compare the new image with that baseline and report differences. Review and commit baseline files deliberately; they are test artifacts tied to browser, operating-system, fonts, viewport, and device-scale assumptions.
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
Use locator assertions for a component:
await expect(page.locator('[data-testid="checkout-summary"]'))
.toHaveScreenshot('checkout-summary.png');
Configure screenshot behavior in the Playwright Test configuration when you want consistent settings across tests:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
screenshot: 'only-on-failure'
}
});
Automatic screenshots after tests are diagnostic artifacts; they are separate from explicit visual assertions. Depending on the setting, Playwright can capture screenshots on failure, on every test, or never. Keep the setting aligned with your CI storage policy because full-page images can consume substantial artifact space.
Complete examples
Full-page Chromium capture with a deterministic viewport
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext({
viewport: { width: 1366, height: 768 },
deviceScaleFactor: 1
});
const page = await context.newPage();
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.locator('body').waitFor();
await page.screenshot({ path: 'example-full.png', fullPage: true, scale: 'css' });
await browser.close();
})();
Capture an element after scrolling it into view
const product = page.getByRole('article').filter({ hasText: 'Starter' });
await product.scrollIntoViewIfNeeded();
await product.screenshot({ path: 'starter-card.png', type: 'png' });
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting
The file is blank, white, or smaller than expected
- Confirm navigation succeeded and wait for the page’s real ready condition.
- Check that the target is not inside an iframe; use
frameLocator()to locate content in a frame. - For full-page captures, verify that the application has rendered content below the fold and that lazy loading is triggered.
- Inspect viewport and device-scale settings; a CSS-sized image and a device-pixel image have different dimensions.
“Target closed” or browser launch errors
Close pages only after awaiting the screenshot buffer or file write. Install the browsers for the exact Playwright package in the environment running the script. In containers, use the documented Playwright container or install required system dependencies.
Locator strictness or timeout failures
The locator may match zero or multiple elements, or the element may never become actionable. Confirm the selector, wait for the component to render, and make the locator unique. If an overlay covers it, dismiss the overlay or capture an unobstructed state intentionally.
Element image omits content
A locator screenshot scrolls the element into view, but it does not expand a scrollable child. Scroll that child yourself, increase its height temporarily, or capture the page region that contains the desired content.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Visual tests fail only in CI
Compare browser version, operating system, fonts, viewport, locale, timezone, and device scale. Disable animations, stabilize data, and avoid baselines generated on a different rendering environment. A legitimate design change requires updating the baseline; a flaky test requires fixing the source of nondeterminism instead.
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.
Performance, reliability, and cost considerations
Each screenshot requires a rendered browser page, so browser startup is usually more expensive than reusing a context and page. Keep one browser process alive for a batch, create isolated contexts for test data, and close pages in a finally block. Full-page and device-scale captures consume more memory and produce larger files than viewport, CSS-scale captures. JPEG or WebP can reduce transfer size when lossless PNG is unnecessary.
For many URLs, control concurrency rather than launching an unbounded number of browsers. Set navigation and assertion timeouts appropriate to your site, retry only transient failures, and record the URL, browser version, viewport, and options with each artifact so a mismatch can be reproduced.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns PNG, JPEG, WebP, or PDF. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—let Claude, Cursor, or another MCP client request captures.
Free tools Windows power users keep installed
One-click scans. No signup required.
Using the API requires no Playwright browser installation:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo documentation for options such as full-page and CSS-selector capture, device presets, retina scale, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, and usage and OpenAPI endpoints. The API accepts parameter names used by other screenshot APIs, which can simplify migration.
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up free for ScreenshotNeo.
Frequently Asked Questions
Can I take a screenshot without saving a file?
Yes. Call const buffer = await page.screenshot() and send or process the returned buffer in memory.
Should I use a page screenshot or a locator screenshot for a component?
Use a locator screenshot for a specific component because it waits for actionability and scrolls the target into view; use a page screenshot for viewport or document captures.
Why do visual snapshots differ between computers?
Rendering depends on browser and operating-system versions, fonts, viewport, device scale, locale, timezone, and dynamic application data. Standardize those inputs before comparing images.
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.

