Use page.screenshot() to capture a Playwright page. With no extra options it saves the visible viewport; add fullPage: true for the complete scrollable document, or use a clip/locator for a region or element. For regression testing, Playwright Test’s expect(page).toHaveScreenshot() creates a baseline on its first run and compares later captures against it.
The dependable workflow is: wait for the application state that matters, choose the smallest capture scope that answers your question, stabilize genuinely dynamic content, and run baselines and comparisons in the same browser and host environment.
Choose the screenshot operation first
Playwright has three closely related workflows. They produce different artifacts and should not be mixed accidentally.
Save an image for a report or pipeline artifact
Call page.screenshot(). The default is the current viewport. Set a path to write a file, or omit it and receive a buffer for further processing.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#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.
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.screenshot({ path: 'artifacts/example.webp', type: 'webp' });
await browser.close();
Use a meaningful readiness condition rather than an arbitrary sleep. For a dashboard, that might be a visible table; for a single-page app, it might be a heading whose text proves the expected route loaded.
Capture the complete scrollable page
Pass fullPage: true. Playwright captures the full scrollable page instead of only the viewport.
await page.goto('https://example.com/docs');
await page.getByRole('heading', { name: 'Documentation' }).waitFor();
await page.screenshot({ path: 'artifacts/docs-full.png', fullPage: true });
Full-page output is useful for documentation and review, but it can be very tall and may expose content that is not visible in the normal user flow. Use a viewport or element capture when the test is about one screen or component.
Capture a rectangle or one element
clip takes an output rectangle in CSS pixels. A locator screenshot automatically uses the element’s bounds and is usually safer than hand-maintained coordinates.
const card = page.getByTestId('summary-card');
await card.screenshot({ path: 'artifacts/summary-card.png' });
const box = await page.locator('#chart').boundingBox();
if (!box) throw new Error('Chart is not visible');
await page.screenshot({
path: 'artifacts/chart-region.png',
clip: box
});
Coordinates are tied to layout. A locator remains meaningful when surrounding content changes, while a fixed clip can move or become invalid after a responsive breakpoint.
Screenshot options that affect the pixels
Format, quality, and transparency
Playwright can produce PNG, JPEG, or WebP (subject to the installed browser’s support). JPEG does not support transparency. Set quality for JPEG/WebP when the resulting file size matters. Set omitBackground: true to preserve transparency in formats that support it.
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.
await page.screenshot({
path: 'artifacts/logo.webp',
type: 'webp',
quality: 85,
omitBackground: true
});
Retain or suppress animation
The default leaves animations enabled. animations: 'disabled' fast-forwards finite animations and cancels infinite ones during the capture, reducing timing-related differences.
await page.screenshot({
path: 'artifacts/stable.png',
animations: 'disabled'
});
Disable animation only when motion is irrelevant to the assertion. If the animation itself is the feature under test, capture at a deliberate state instead.
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 matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallMask changing content
Pass locators in mask to cover their bounds. maskColor chooses the overlay color. Masking also applies to invisible elements, so inspect the resulting image and your locator set carefully: a masked area is intentionally hidden from visual review.
await page.screenshot({
path: 'artifacts/profile.png',
mask: [page.getByTestId('timestamp'), page.locator('.avatar')],
maskColor: '#ff00aa'
});
Prefer masking a truly irrelevant clock, random identifier, or rotating ad. Do not mask a region simply because it is currently failing; that removes the evidence the test is meant to provide.
Use a stylesheet for broader normalization
For visual assertions, a custom stylesheet can hide or normalize volatile content across a page. Keep this CSS narrow and documented, because it changes what the comparison can observe.
Playwright Test visual comparisons
Use expect(page).toHaveScreenshot() when the goal is a repeatable visual regression check rather than a one-off file.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair 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.
import { test, expect } from '@playwright/test';
test('checkout summary remains stable', async ({ page }) => {
await page.goto('https://example.com/checkout');
await expect(page.getByRole('heading', { name: 'Checkout' })).toBeVisible();
await expect(page).toHaveScreenshot('checkout.png', {
fullPage: true,
animations: 'disabled',
mask: [page.getByTestId('live-clock')]
});
});
How baselines work
On the first execution, Playwright Test creates the reference snapshot. Later executions capture the page and compare it with that reference. Review intentional UI changes before updating snapshots; accepting every proposed update defeats the purpose of the test.
The assertion waits for two consecutive screenshots to match before comparing them. That helps with short-lived layout movement, but it does not make an unstable application deterministic. You still need a meaningful readiness check and controlled data.
Generate and review a baseline
- Run the test in the environment you intend to use for comparisons. The first run creates the snapshot.
- Open the generated image and verify fonts, data, responsive layout, and any masked regions.
- Change the UI deliberately and rerun the test. Inspect the diff rather than treating a failure as proof of an application bug.
- When the change is intentional, update the baseline through your project’s normal Playwright Test snapshot-update command and review that diff in code review.
Why screenshots differ across operating systems
Pixel output depends on more than HTML and CSS. Operating system, browser version, browser settings, hardware, power source, and headless mode can all affect font rasterization, antialiasing, viewport metrics, and image decoding. A difference may therefore be an environment change rather than a product defect.
- Pin the Playwright and browser versions used by the project.
- Run baseline creation and comparison on the same operating-system image, viewport, device scale, and headless setting.
- Use consistent fonts and install every font your page requires.
- Control locale, timezone, color scheme, reduced-motion preference, and test data when those values appear in the UI.
- Keep network-dependent content deterministic or stub it at the application boundary.
When a diff appears, first reproduce it in the baseline environment. If it disappears there, fix environment drift before changing application code or masking pixels.
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 →Practical capture patterns
Viewport screenshot after a state transition
await page.goto('https://example.com/settings');
await page.getByRole('button', { name: 'Advanced' }).click();
await expect(page.getByRole('heading', { name: 'Advanced settings' })).toBeVisible();
await page.screenshot({ path: 'artifacts/advanced-viewport.png' });
Lazy-loaded content in a full-page shot
Scroll or otherwise trigger the application’s lazy-loading behavior before capture, then wait for the content-specific locator. A full-page request is not a substitute for proving that every image or card has loaded.
await page.goto('https://example.com/catalog');
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await page.getByTestId('catalog-footer').waitFor();
await page.screenshot({ path: 'artifacts/catalog.png', fullPage: true });
Python Playwright equivalent
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(viewport={"width": 1440, "height": 900})
page.goto("https://example.com", wait_until="domcontentloaded")
page.get_by_role("heading", name="Example Domain").wait_for()
page.screenshot(path="artifacts/example.png", full_page=True)
browser.close()
Playwright MCP screenshots are a separate workflow
Playwright MCP screenshot tooling is an interactive browser interface, not the Playwright Test assertion API. Its documented operations cover viewport, element, and full-page captures, with PNG, JPEG, and WebP output and CSS-pixel or device-pixel scaling. Use it when an AI agent or interactive inspection needs an image; use toHaveScreenshot() when a test suite must establish and enforce a baseline. For page structure or text, an accessibility snapshot is more appropriate than a screenshot.
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
Common failures and fixes
The file contains only the visible screen
Cause: viewport capture is the default. Fix: add fullPage: true, or capture a specific locator if the entire document is unnecessary.
A clip throws or captures the wrong area
Cause: coordinates are stale, outside the viewport, or the element has no layout box. Fix: wait for the target, obtain a fresh boundingBox(), check for null, or use locator.screenshot().
Recommended Free Tools
Visual tests fail intermittently
Cause: animations, clocks, ads, random data, lazy loading, or asynchronous layout. Fix: assert a meaningful ready state, disable animations where appropriate, mask only irrelevant locators, normalize with a focused stylesheet, and make test data deterministic.
The same test differs by machine
Cause: rendering-environment drift. Fix: align OS image, browser and Playwright versions, fonts, viewport, scale, settings, hardware conditions, and headless mode.
A masked region hides a real regression
Cause: the mask is too broad or the wrong locator matched. Fix: narrow the locator, inspect the masked output, and keep functional assertions for the data that the visual test intentionally hides.
Full-page output is unexpectedly huge
Cause: the document is genuinely long or includes expanded/lazy content. Fix: capture a component or clip, or split the page into meaningful regions. Do not shrink the image until text is unreadable merely to fit a report.
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.
Performance, reliability, and cost choices
- Viewport: usually the smallest and fastest artifact for a user-flow checkpoint.
- Element or clip: reduces noise and file size when one component is under test.
- Full page: gives broad coverage but takes more memory and creates larger review diffs.
- PNG: lossless and suitable for exact comparisons; JPEG/WebP can reduce storage when slight encoding differences are acceptable.
- Visual assertions: keep snapshots near the test that owns them, and avoid one enormous baseline that makes unrelated changes hard to review.
Screenshot reliability comes from deterministic state, not from repeatedly retrying a flaky capture. Retries can hide a race and make a baseline appear trustworthy when it is not.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server when you need a clean URL-to-image or PDF request without maintaining Playwright browsers. Before capture it accepts the cookie/consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—work with Claude, Cursor, and other MCP clients.
One GET request returns PNG, JPEG, WebP, or PDF. See the ScreenshotNeo documentation for the full option list, including full-page and selector captures, dark mode, device presets, retina scale, PDF margins and page ranges, custom CSS/JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, TTL caching, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and the OpenAPI specification.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and yearly billing gives two months free. Create a free ScreenshotNeo account to try the API.
Frequently Asked Questions
Can I screenshot a single Playwright element?
Yes. Call locator.screenshot(); Playwright uses that element’s bounds and writes the image to the path you provide.
Should I use a screenshot or an accessibility snapshot for text checks?
Use an accessibility snapshot for structure and text. Use screenshots for visual appearance, layout, and rendering differences.
Does fullPage guarantee every lazy image is loaded?
No. Trigger the application’s lazy-loading behavior and wait for a meaningful content locator before requesting the full-page image.
What is the difference between MCP screenshots and toHaveScreenshot()?
MCP is an interactive capture interface with viewport, element, full-page, format, and scale choices. toHaveScreenshot() is a Playwright Test assertion that creates and compares baselines.
Free tools Windows power users keep installed
One-click scans. No signup required.
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.

