Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a UI screenshot with Playwright, navigate to the page and call await page.screenshot({ path: 'screenshot.png' }). Add fullPage: true to capture the full scrollable page, or call screenshot() on a locator to capture one element. For repeatable visual regression checks, use Playwright Test’s toHaveScreenshot() assertion instead of treating a one-off file capture as a test.

Set up a basic Playwright screenshot

The shortest workflow is: launch a browser, create a page, navigate to a URL, save the screenshot, and close the browser. The example below uses Playwright’s JavaScript library and Chromium. Install the package and its browser before running the script:

npm install playwright
npx playwright install chromium

Save this as screenshot.js, then run node screenshot.js:

const { chromium } = require('playwright');

(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 output file is written to the current working directory. Replace the example URL with the page you want to capture. If your script already has a page object, the essential call is simply await page.screenshot({ path: 'screenshot.png' }). Without additional options, it captures the viewport.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Choose what part of the UI to capture

Capture the visible viewport

Use page.screenshot() without a full-page or clip option when you need the portion of the page currently visible in the viewport. This is a useful fit for a single screen, a debugging artifact, or a capture whose dimensions should match the browser viewport.

Capture the full scrollable page

Pass fullPage: true to capture beyond the visible viewport:

await page.screenshot({
  path: 'full-page.png',
  fullPage: true
});

This asks Playwright to capture the full scrollable document. A full-page image can be much taller than a viewport screenshot, so use it when the entire page is relevant rather than when you only need the visible UI.

Capture one element

Use a locator’s screenshot() method to save a particular component, such as a header, card, chart, or dialog:

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.
await page.locator('.header').screenshot({ path: 'header.png' });

Locator screenshots scroll the element into view after actionability checks. They do not reveal pixels hidden behind another element: if an overlay covers part of the target, that can affect the captured result. For a scrollable container, the screenshot includes only the content currently scrolled into view, not every item inside that container.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Capture a defined rectangle

When neither the whole viewport nor a DOM element is the right boundary, pass a clip rectangle to page.screenshot(). The rectangle lets you target a region of the page; choose its position and dimensions for the UI area you need. A clip is a geometric crop, while a locator screenshot is tied to an element and its visibility and scroll position.

Save an image file or keep the screenshot in memory

Providing path writes the image to disk. Omit path when another step in your script needs the image data directly:

const buffer = await page.screenshot();
// Pass buffer to another step in your application.

The returned buffer can be post-processed or passed to another tool. This is useful when a test or service needs to inspect, upload, or transform the image without first choosing a local filename.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose format, scale, and stable-capture options

Image format

Playwright documents PNG, JPEG, and WebP screenshot output. A path extension can select the format, for example shot.png, shot.jpg, or shot.webp. JPEG does not support a transparent background, so choose another format if transparency matters. Match the format to the next step in your workflow: a format supported by a destination is more useful than a smaller file it cannot accept.

Pixel scale

The scale option determines the relationship between CSS pixels and output pixels:

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
  • scale: 'css' produces one image pixel per CSS pixel.
  • scale: 'device' produces one image pixel per device pixel. On a high-DPI device, that can create a larger image.

Use CSS scale when you need image dimensions aligned with the page’s CSS-pixel layout. Use device scale when the extra device-pixel detail is wanted and the larger output is acceptable.

Reduce variation from animation and dynamic content

Animations can make captures vary from run to run. Playwright’s animations: 'disabled' option changes animation behavior during capture. Screenshot options also include masks for element bounding boxes, and a screenshot style can hide or alter dynamic content. Use these tools to control known sources of variation, not to cover up a genuine UI change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use screenshots in visual regression tests

A saved screenshot is a capture; a visual assertion is a comparison performed as part of a test. With Playwright Test, use toHaveScreenshot() when the purpose is to detect visual changes:

import { test, expect } from '@playwright/test';

test('home page appearance', async ({ page }) => {
  await page.goto('https://example.com');
  await expect(page).toHaveScreenshot('home.png');
});

Keep the expected capture meaningful by filtering genuinely volatile content. Playwright Test supports stylePath for filtering such content, and screenshot assertions expose diff-tolerance settings. Tune tolerance only for known rendering variation; overly permissive settings can make real visual changes harder to catch. This test assertion serves a different purpose from calling page.screenshot({ path: ... }) to save an artifact.

Save screenshots automatically when tests fail

Playwright Test’s use.screenshot configuration can enable screenshots on failure or on the first failure. This is useful when a failure artifact should be collected automatically rather than adding a manual screenshot call to each test. Choose the failure behavior that matches how your test run handles retries and artifacts.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Or skip the browser setup

If you need an image from a URL without launching and managing Playwright in your own script, ScreenshotNeo provides a screenshot API and MCP server for developers. A single GET request can return a PNG, JPEG, WebP, or PDF. For example, this cURL call saves a WebP screenshot of a page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request parameters. Python and Node.js examples are available if those fit your workflow better:

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}`);
  • Cookie banners are accepted as a visitor and removed along with known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing. Response headers report the page verdict and whether the request was billed.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, 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’s free plan to try 1,000 screenshots a month without a card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common screenshot problems

The image is blank or missing the UI

Check that the script navigated to the intended URL before taking the screenshot. If the UI is not present yet, capture after the page or target element is ready instead of relying on the immediate next line after navigation. For an element-specific capture, confirm the locator identifies the intended element and that the element can be brought into view.

The element capture is cut off or obscured

A locator screenshot captures the element in its actual visible context. If another element overlays it, the overlay can remain part of the result; a locator screenshot is not a way to reveal covered content. If the target sits in a scrollable container, scroll the container to the content you want before capturing, because the element capture does not include all off-screen contents of that container.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

The full-page capture misses images or appears incomplete

Full-page mode targets the scrollable page, but content that loads lazily may not yet be present when the capture occurs. Wait for the relevant content to load before taking the screenshot, and inspect whether the page itself has loaded the images you expect. Full-page capture changes the capture extent; it does not guarantee that every deferred asset has already appeared.

The file format or dimensions are wrong

Check the output path extension and the selected scale. The extension can choose PNG, JPEG, or WebP output; scale: 'css' and scale: 'device' produce different pixel dimensions on high-DPI devices. If you need transparency, do not choose JPEG.

A visual test fails intermittently

Look for animation or dynamic content that changes between runs. Disable animations for the capture, mask or style known volatile regions, or use stylePath in Playwright Test to filter content that should not affect the comparison. Adjust diff tolerance only for understood rendering variation; do not use it as a substitute for investigating an unexpected difference.

The script does not produce a file

Confirm that the script reaches the screenshot call and that the path points to a writable location. If there is no path option, Playwright returns image data instead of writing the file, so save or pass along that buffer explicitly. Also ensure the browser is closed after the capture, including when an earlier operation throws, as in the try/finally example above.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which Playwright screenshot method should you use?

Need Use What to account for
Visible page or debug artifact page.screenshot() Captures the viewport unless you change the extent.
Entire scrollable document page.screenshot({ fullPage: true }) Wait for the content you need, including lazy-loaded content.
One component locator.screenshot() Visibility, overlays, and scroll position still matter.
Pass image data to another step page.screenshot() without path Handle the returned buffer in your application.
Detect a visual change in tests Playwright Test’s toHaveScreenshot() Control known dynamic content and use tolerance carefully.

Option availability can differ by Playwright language, browser engine, and release. For a version-specific option or compatibility question, consult the API documentation for the Playwright version installed in your project.

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.