For repeatable website screenshots, first choose what the image needs to show: the visible viewport, a single component, or the full page. Then automate the browser state, capture with deliberate output settings, and—when checking visual changes—compare stable captures against an approved baseline. Playwright documents all three capture scopes and includes screenshot assertions in Playwright Test; Puppeteer provides a JavaScript browser-automation API for screenshot capture.
Choose the screenshot scope before choosing a tool
A screenshot is only useful when its boundaries match the question you need it to answer. Playwright documents viewport, element, and full-page capture. Those modes represent different things and are not interchangeable.
- Viewport: captures the currently visible browser area. Use it to record above-the-fold appearance, a particular responsive breakpoint, or what a user sees without scrolling.
- Element: captures a chosen component, such as a navigation bar, card, or dialog. This is useful for focused component review, but Playwright’s screenshot command does not combine a single-element target with full-page capture.
- Full page: includes content below the fold. Use it for long-page review or a complete visual record. It does not mean that the page’s browser state or content is automatically made stable.
Playwright describes these capture modes and their uses in its Screenshots documentation. For any mode, decide which URL, viewport, and interaction state the image should represent before capturing it.
How to automate a website screenshot with Playwright
Playwright is a practical choice when you want browser automation and, potentially, visual assertions in the Playwright Test runner. Install the package and browser binaries for the browser you intend to use, then save this as an ES module—for example, capture.mjs.
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 problems#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.
Install
With Node.js and npm installed, run:
npm init -y
npm install playwright
npx playwright install chromium
Capture a full page
This runnable script navigates to a URL, waits for the page’s load event, and writes a full-page PNG. Set the target URL through the TARGET_URL environment variable or change the default.
import { chromium } from 'playwright';
const url = process.env.TARGET_URL ?? 'https://example.com';
const browser = await chromium.launch({ headless: true });
try {
const page = await browser.newPage({
viewport: { width: 1440, height: 900 },
deviceScaleFactor: 1
});
await page.goto(url, { waitUntil: 'load', timeout: 30_000 });
await page.screenshot({ path: 'screenshot.png', fullPage: true });
} finally {
await browser.close();
}
Run it with TARGET_URL=https://your-site.example node capture.mjs. The fullPage: true option asks Playwright to include content beyond the initial viewport; omit it for a viewport screenshot. Playwright’s page screenshot API documents options such as full-page capture, masks, and transparent backgrounds at Page.
Capture one element
Replace the screenshot line with a locator capture to isolate a component. The selector must match an element on the loaded page:
const component = page.locator('[data-testid="pricing-card"]');
await component.screenshot({ path: 'pricing-card.png' });
If the selector matches no visible element, the capture cannot produce the intended component image. Use a stable selector owned by your application rather than a fragile positional selector where possible.
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 →Repair Windows errors before they cause bigger problemsFix Now →Set output options for the job
Choose format, scale, clipping, and background based on how the image will be consumed. Playwright’s screenshot tooling exposes format and scale controls. Its page API also supports masks and transparent backgrounds. For example, to write JPEG output:
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: 'screenshot.jpg',
type: 'jpeg',
quality: 80,
fullPage: false
});
Use a clip rectangle when the capture should be limited to a particular region, and use transparency only when the output needs to preserve a transparent background. A test baseline must use the same viewport and scale as the run being compared; otherwise, a difference may reflect capture settings rather than a UI change. Consult the Playwright Page API for the options and accepted values in your installed version.
How to automate screenshots with Puppeteer
Puppeteer is a JavaScript browser-automation library. Chrome for Developers describes automating Chrome and Firefox through CDP and WebDriver BiDi. Its screenshot options include full-page and clipped captures, output type, file path, JPEG quality, and transparency settings. The reviewed options documentation is for Puppeteer 25.12.0; verify behavior against the documentation for the version you install.
Install and capture
Install Puppeteer and save the following as capture-puppeteer.mjs. This example launches its managed browser, opens a page, and saves a full-page PNG:
Free tools Windows power users keep installed
One-click scans. No signup required.
npm init -y
npm install puppeteer
import puppeteer from 'puppeteer';
const url = process.env.TARGET_URL ?? 'https://example.com';
const browser = await puppeteer.launch({ headless: true });
try {
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 900 });
await page.goto(url, { waitUntil: 'load', timeout: 30_000 });
await page.screenshot({ path: 'screenshot.png', fullPage: true });
} finally {
await browser.close();
}
Run it with TARGET_URL=https://your-site.example node capture-puppeteer.mjs. For a viewport capture, set fullPage: false or omit the option. For an element, use an element handle or locator and its screenshot method; for a region, configure a clip rectangle. Puppeteer documents the details in its ScreenshotOptions interface, and Chrome’s overview is at Puppeteer.
Playwright or Puppeteer: which workflow fits?
Both can automate a browser and capture screenshots. The useful distinction in the reviewed official documentation is the documented regression workflow: Playwright Test includes a screenshot assertion, while the reviewed Puppeteer sources establish capture options but do not establish a built-in equivalent assertion. That distinction does not mean Puppeteer cannot be used with a separate comparison workflow.
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.
| Decision | Playwright | Puppeteer |
|---|---|---|
| Documented capture scope | Viewport, element, and full page; format and scale controls. | Full page and clip options, with output type and quality settings. |
| Visual regression in reviewed docs | Playwright Test’s toHaveScreenshot assertion, with stability and masking options. |
Reviewed sources document capture options; a built-in equivalent assertion is not established there. |
| Browser automation described in reviewed sources | Screenshot API and test-runner assertions. | Chrome and Firefox automation through CDP and WebDriver BiDi, as described by Chrome for Developers. |
Choose Playwright when its integrated test-runner assertion is useful for your workflow. Choose Puppeteer when its JavaScript browser-automation API and capture options fit your project. This comparison reflects the cited documentation, not a claim that either tool lacks capabilities that were not covered there.
How to compare screenshots for visual regression testing
A visual comparison is meaningful only if the test recreates a defined state. Before recording or updating a baseline, decide what should remain visually consistent and which parts of the page are expected to change.
Recommended Free Tools
- Establish the state: navigate to the intended URL, set the viewport, and perform the interactions needed to reach the target screen. Put those steps in the test instead of relying on a person to reproduce them.
- Choose the capture boundary: use viewport capture for a screen region, a locator for one component, or full-page capture for a long page.
- Keep comparison inputs consistent: use the same browser setup, viewport, scale, and relevant page state when producing the baseline and later captures.
- Control unstable regions: disable animations when appropriate and mask content that changes but is outside the visual contract, such as a timestamp or rotating promotion.
- Review differences as evidence, not a verdict: investigate whether a diff indicates a defect, an intended design change, or an uncontrolled condition before accepting or rejecting it.
Use Playwright Test’s screenshot assertion
Playwright Test’s toHaveScreenshot assertion waits for two consecutive screenshots to match before comparing with an expected image. This reduces the chance of comparing a transient rendering, but it does not make every page deterministic. A simple test can look like this:
import { test, expect } from '@playwright/test';
test('homepage visual appearance', async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 900 });
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('homepage.png', {
fullPage: true,
animations: 'disabled'
});
});
Run it with npx playwright test. On an initial run, the test runner creates the expected image; subsequent runs compare captures against it. Review and deliberately update expected images when a design change is intended rather than treating every new baseline as automatically correct. Playwright documents the assertion behavior, animation controls, masking, and comparison options in PageAssertions.
To mask a changing region, pass a locator in the assertion options. For example, add mask: [page.locator('[data-testid="live-clock"]')] to the options object. Mask only content that is deliberately outside the test’s visual contract: masking a real layout defect can conceal it.
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
When screenshots are the wrong test evidence
Screenshots answer visual questions: whether layout, styling, or rendered canvas and chart content looks right, or what a bug looked like at a particular moment. They do not prove that a control is accessible, that page structure is correct, or that text and interaction semantics behave properly.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →For interaction references, page structure, and text, use accessibility snapshots or other semantic checks alongside visual captures. Playwright explicitly distinguishes those purposes in its Screenshots guidance, which says, “Screenshots complement accessibility snapshots:” A pixel image alone cannot establish accessible semantics.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Make automated captures reliable and economical
Stabilize the target, not just the screenshot call
A capture can differ because of dynamic content, overlays, viewport changes, or a legitimate UI update. Decide which of these changes matter for each test. Disable animations and mask only known, irrelevant moving regions; make the rest of the page deterministic where you can. No screenshot API option establishes universal pixel identity across operating systems, browsers, fonts, or deployments.
Handle long pages and loading deliberately
Full-page capture is appropriate when the material below the fold is part of the review, but it can create large images and make a single diff harder to diagnose. Prefer an element or viewport capture when the question concerns one component or screen. The examples wait for the page load event; pages that populate content later may need a more specific wait for the state under test. Waiting a fixed delay can help in a narrow case, but waiting for an application-specific selector is usually a clearer expression of the desired state.
Budget for what you actually compare
The cited Playwright and Puppeteer documentation establishes capture and assertion behavior, not comparative speed, operating cost, or a universal best tool. In a test suite, the practical workload depends on how many pages and states you capture and how much image data you retain. Keep baselines tied to clearly named tests and review changes rather than producing redundant full-page images when a focused capture answers the question.
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.
Troubleshooting common screenshot problems
- The output is blank or missing: check that navigation reached the expected URL and that the page or target element exists before capturing. If content appears after the load event, wait for the relevant application state rather than assuming the initial load is enough.
- The element capture fails: confirm the selector matches an element and that it is visible. Use a stable test ID or application-owned selector and wait for that element to appear.
- A visual test fails intermittently: identify changing content, animations, overlays, and inconsistent viewport settings. Disable animations or mask a specific irrelevant region; do not mask content that the test is meant to protect.
- The screenshot is cut off: verify that full-page capture is enabled when the page extends below the viewport. If capturing a component, remember that a single-element target and full-page mode cannot be combined in Playwright’s screenshot command.
- Images or charts are absent: ensure the page has reached the state where those assets are rendered. Wait for a meaningful selector or application signal rather than relying on an arbitrary delay alone.
- Baseline differences appear after an environment change: check browser, viewport, scale, and deployment state before attributing the diff to a product regression. Review the image and baseline update intentionally.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. Its API returns a screenshot or PDF from one GET request; the example below saves a WebP capture. See the ScreenshotNeo documentation for API options and setup.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo free to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can I use a screenshot to test accessibility?
No. A screenshot shows visual rendering, not accessible semantics; pair it with accessibility snapshots or semantic checks.
Does Playwright’s screenshot assertion guarantee identical pixels on every machine?
No. Its documented stability wait and masking controls do not establish universal pixel identity across operating systems, browsers, fonts, or deployments.
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.

