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

Use await page.screenshot({ path: 'screenshot.png' }) to capture the current browser viewport, fullPage: true to capture the full scrollable page, or locator.screenshot() to capture a particular element. The examples below use Playwright’s JavaScript API and show how to save an image, return it as a buffer, make captures more repeatable, and use screenshots in Playwright Test.

Set up a page and take your first screenshot

The screenshot methods work on a Playwright Page that has already been created. Here is a minimal JavaScript example using Playwright’s Chromium browser:

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();
})();

Install the Playwright package in your project with npm install playwright. If you use the Playwright Test runner, install and use @playwright/test instead. A screenshot call does not guarantee that an application’s asynchronous content has finished rendering: navigate, then wait for a readiness signal that matches the page and test, such as a particular element becoming visible.

The basic call captures the current viewport and saves it to the path you provide. The official Playwright screenshots guide also demonstrates the basic save-to-file workflow. The guide is labeled Next; check the documentation for the Playwright version installed in your project when relying on an option that may have been added in a newer release.

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 page to capture

Current viewport

Use page.screenshot() without a scope option when you want the page as it appears in the current browser viewport:

await page.screenshot({ path: 'viewport.png' });

This does not capture the entire document below the fold. The Page API documents fullPage as defaulting to false.

Full scrollable page

Set fullPage: true to capture the full scrollable page as one tall image, rather than only the visible viewport:

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

Playwright describes this as capturing a full scrollable page “as if you had a very tall screen and the page could fit it entirely.” See the Page API for the option and its behavior. Full-page capture is useful for an overview of a long page, but it is not the same as a paginated PDF or a screenshot of one chosen region.

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

One element

To capture a matched element, call screenshot() on a locator:

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

Locator screenshots perform actionability checks and scroll the element into view. If the target is a scrollable container, the image shows its currently scrolled content; it does not expose portions hidden outside the visible area. Playwright recommends locators over the discouraged elementHandle.screenshot() method. Consult the Locator API for the element screenshot behavior and locator options.

Explicit rectangle

Use clip when the capture should be a specific rectangle on the page, rather than the whole document or a selected element:

await page.screenshot({
  path: 'region.png',
  clip: { x: 20, y: 30, width: 640, height: 360 }
});

The rectangle is defined by its x and y position and its width and height. Use a locator when the target is a particular page element; use clip when you need a fixed page region. The available page screenshot options are documented in the Page API.

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.

Save an image or keep it in memory

Passing path writes the screenshot to a file. If you omit path, the method returns a buffer that you can process, encode, or pass to another tool:

const buffer = await page.screenshot();
console.log(buffer.toString('base64'));

The base64 form can be useful when you need to transport image data as text, but it is larger than the binary buffer. The screenshots guide demonstrates both a returned buffer and base64 conversion. For file output, choose a path that makes sense for your project and test artifacts; ensure the parent directory exists if your script expects to write into a nested directory.

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.

Set format, quality, and pixel scale

Playwright supports PNG, JPEG, and WebP screenshots. PNG is the default; when saving to a path, the file extension can determine the output format. The quality option applies to JPEG and WebP, not PNG. JPEG defaults to quality 80, while WebP quality 100 is lossless.

await page.screenshot({
  path: 'compressed.webp',
  type: 'webp',
  quality: 80
});

The scale option controls output pixels relative to CSS pixels. scale: 'css' produces one image pixel per CSS pixel; scale: 'device' produces one pixel per device pixel and is the Page API’s documented default. On a high-DPI device, device scale can make an image twice as large or more than CSS scale. Consider CSS scale when smaller files or dimensions matching CSS layout are preferable; retain device scale when the higher-resolution output is important.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({
  path: 'css-pixels.png',
  scale: 'css'
});

Use omitBackground: true to omit the default white background for formats that support transparency. It does not apply to JPEG, which does not support transparent pixels. These format, quality, scale, and background options are described in the Page API.

Make captures repeatable and protect sensitive regions

Visual output can change between runs because of animation, personalized content, timestamps, or other dynamic regions. Playwright offers screenshot options to help control those differences, but they do not replace a page-specific readiness check.

Disable animations

Animations are allowed by default. Set animations: 'disabled' to stop CSS animations, transitions, and Web Animations for the capture. Finite animations are fast-forwarded; infinite animations are canceled for capture and resume afterward.

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
await page.screenshot({
  path: 'stable.png',
  animations: 'disabled'
});

Mask changing or private regions

Mask locators when their pixels are unpredictable or should not appear in the output. The mask covers each matched locator’s bounding box, and you can choose its color:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({
  path: 'masked.png',
  mask: [page.locator('.account-number')],
  maskColor: '#000000'
});

A mask covers the selected area in the image; it does not remove the underlying content from the page or from the browser context. Treat screenshot files as sensitive if the page contains private data, and do not rely on masking as a substitute for access controls. For other changing elements, a stylesheet can hide or adjust them before capture. Screenshot styles, animation handling, and masks are documented in the Page API and Locator API.

Capture screenshots automatically in Playwright Test

Manual page.screenshot() calls are separate from Playwright Test’s automatic screenshot artifacts. To configure automatic capture, set the Test runner’s screenshot option. Its documented modes are off, on, only-on-failure, and on-first-failure; the default is off.

import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    screenshot: 'only-on-failure',
  },
});

Use on when the configured automatic screenshots should be captured for every test, or choose a failure mode when artifacts are primarily for investigating failed runs. See the TestOptions reference for the runner setting and behavior.

For visual regression assertions, use expect(page).toHaveScreenshot() or expect(locator).toHaveScreenshot() with Playwright Test. The assertions wait until two consecutive screenshots are the same and compare the result with the expectation. They are test-runner features, not replacements for calling page.screenshot() in a standalone script. The relevant APIs are documented in PageAssertions and LocatorAssertions.

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.
Best Value
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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common screenshot problems and fixes

  • The image only shows the top of the page. The default captures the viewport. Set fullPage: true when the full scrollable document is intended.
  • The target element is missing or not where expected. Confirm the locator matches the intended element and that the page has reached the required state before capture. Locator screenshots scroll the element into view, but they cannot reveal content obscured by an overlay or outside a scrollable container’s currently visible area.
  • The screenshot is blank or missing content that loads later. A screenshot call does not establish that asynchronous application work has completed. Wait for an application-specific signal before calling it, rather than assuming navigation alone means the page is visually ready.
  • Images differ across runs. Disable animations, mask changing regions, or use a stylesheet to stabilize content. If content appears late, wait for the relevant page condition first; animation controls do not make asynchronous data deterministic.
  • The output is larger than expected. Device-pixel scale can produce more pixels on a high-DPI device. Try scale: 'css', or use JPEG/WebP quality where lossy output is acceptable. PNG ignores the quality option.
  • A transparent image has a white background. Use omitBackground: true with a transparency-supporting format. This option does not apply to JPEG.
  • Automatic test screenshots are not appearing. Check the Playwright Test configuration: its automatic screenshot mode defaults to off. Set an appropriate mode such as only-on-failure if that is the desired artifact behavior.
  • A newer option is unavailable. Screenshot options can be version-dependent. Check the API documentation corresponding to the installed Playwright release rather than assuming a feature on the Next guide exists in an older project version.

Or skip the browser setup

If you need an image from a URL without launching and managing a Playwright browser in your own script, ScreenshotNeo provides a screenshot API and MCP server. A single GET request returns a PNG, JPEG, WebP, or PDF; for example, this cURL command saves a WebP capture:

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 options and response details. Cookie banners and consent notices, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response indicates the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan to try it.

Java option

Playwright’s screenshot API is also documented for Java. If your automation project uses Java rather than JavaScript, use the Java-specific Playwright screenshots guide and match its examples to the Java version and setup in your project.

Frequently Asked Questions

Can I use Playwright screenshots for visual regression tests?

Yes. Playwright Test provides page and locator screenshot assertions that wait for consecutive screenshots to stabilize and compare them with expectations. They require the Playwright Test runner.

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

Does a full-page screenshot capture every part of a page?

It captures the full scrollable page as a tall image. It is distinct from capturing only the viewport, a clipped rectangle, or a particular element.

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.