Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
browser automation

How to Capture Screenshots With Playwright (and What “shell.screenshot” Means)

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.

Playwright does not expose an API named shell.screenshot. For browser screenshots, the documented methods are page.screenshot() for a page and locator.screenshot() for one element. The examples below show how to save viewport, full-page and element images, return image bytes, use the command-line interface, and avoid common rendering problems.

What “shell.screenshot” refers to

The exact name shell.screenshot is not a Playwright browser API. Playwright’s JavaScript API uses page.screenshot() and locator screenshots. The bracketed name [shell.screenshot] appears in Noctalia documentation for desktop screenshot output, which is a different project. If you are automating a website, use the Playwright methods in this guide rather than trying to call shell.screenshot.

Set up a minimal Playwright project

  1. Create a directory and initialize Node.js:
    mkdir playwright-shots
    cd playwright-shots
    npm init -y
    npm install playwright
    npx playwright install
  2. Create capture.js and run it with node capture.js. The browser installation step downloads the browser binaries that Playwright launches.

How do I take a screenshot with Playwright?

Navigate to the page, call page.screenshot(), then close the browser. Supplying path writes the image to disk.

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

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext({
    viewport: { width: 1440, height: 900 }
  });
  const page = await context.newPage();

  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await page.screenshot({ path: 'example.png' });

  await browser.close();
})();

PNG is the documented default. Replace the filename with a .jpg or .webp name and set the matching type when you need another format:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
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
await page.screenshot({ path: 'example.webp', type: 'webp', quality: 85 });

When path is omitted, the method returns a buffer instead of creating a file. That is useful for an upload, an HTTP response, or image processing:

const image = await page.screenshot({ type: 'png' });
require('fs').writeFileSync('example.png', image);

Viewport versus full-page capture

Capture only the visible viewport

The default screenshot contains what is currently visible in the browser viewport. Scrolling the page before the call changes which portion is captured.

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

Capture the entire scrollable page

Set fullPage: true to capture the page’s full scrollable height in one image:

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

Very long pages can produce very large files and may expose layout issues caused by lazy loading, sticky headers or animations. If content appears only after scrolling, trigger that behavior first or wait for the relevant selector before capturing.

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

How do I screenshot an element?

Use a locator rather than the older ElementHandle screenshot API. Playwright waits for locator actionability checks and scrolls the matching element into view.

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

A locator screenshot includes the matched element’s visible box. If another element covers it, the covered portion will not appear as visible content. A scrollable container contributes only the content currently visible inside that container; it is not automatically expanded to include every child.

Make the target deterministic

const card = page.getByTestId('pricing-card');
await card.waitFor({ state: 'visible' });
await card.screenshot({
  path: 'pricing-card.png',
  animations: 'disabled'
});

Prefer stable test IDs or specific CSS selectors. A selector matching multiple elements can make the operation fail or target an unintended node; narrow it with .first(), .nth(), or a more precise locator.

Useful screenshot options

Option Use Example
path Save an image file. Parent directories must already exist. { path: 'artifacts/home.png' }
type Choose png, jpeg or webp where supported. { type: 'jpeg' }
quality Set lossy JPEG/WebP quality; it does not affect PNG. { type: 'jpeg', quality: 80 }
fullPage Include the full scrollable page rather than the viewport. { fullPage: true }
scale Choose CSS-pixel output or device-pixel output. Device scale can create larger high-DPI images. { scale: 'css' }
animations Disable or allow CSS/Web animations during capture. { animations: 'disabled' }
mask Cover dynamic regions with a mask color for stable comparisons. { mask: [page.locator('.timestamp')] }
style Inject CSS that applies only while the screenshot is taken. { style: '.cursor{visibility:hidden}' }

CSS scale makes one output pixel correspond to one CSS pixel. Device scale uses device pixels and can substantially increase dimensions on a high-DPI context. Choose one consistently when comparing images.

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

Waiting for the page to be ready

A screenshot captures the current state, not an eventual state. Use a navigation wait condition, an explicit selector wait, or a short delay only when the page has a known timed transition.

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.
await page.goto('https://example.com/dashboard', {
  waitUntil: 'domcontentloaded'
});
await page.locator('[data-testid="dashboard"]').waitFor({ state: 'visible' });
await page.screenshot({ path: 'dashboard.png' });

For images that lazy-load, wait for the image to complete:

await page.locator('img.hero').waitFor({ state: 'visible' });
await page.locator('img.hero').evaluate(img => {
  if (!img.complete) return new Promise(resolve => {
    img.addEventListener('load', resolve, { once: true });
    img.addEventListener('error', resolve, { once: true });
  });
});
await page.screenshot({ path: 'hero.png' });

Use a fixed viewport, timezone, locale, color scheme and test data when repeatability matters. Disable or mask clocks, rotating banners, random IDs and live counters.

Command-line screenshots

Playwright’s CLI can capture a page or a target element without writing a JavaScript file. The viewport command accepts a filename, while the target form captures a selected element.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx playwright screenshot https://example.com viewport.png
npx playwright screenshot --full-page https://example.com full-page.png
npx playwright screenshot --device="Desktop Chrome" https://example.com desktop.png

Check the installed CLI’s help for the exact options available in your Playwright version:

npx playwright screenshot --help

CLI screenshots are convenient for one-off captures. For authentication, custom waits, masking, cookies, or repeatable test fixtures, a script or Playwright Test gives you more control.

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

Screenshot capture in Playwright Test

Playwright Test can save screenshots after tests or only when they fail. Its visual assertion API compares a new capture with a reference:

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

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

Reference images are environment-sensitive. Operating-system font rendering, browser version, settings, hardware, power source and headless mode can all change pixels. Generate and compare baselines in the same environment, and update them deliberately when the rendering change is expected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

“shell.screenshot is not a function”

That name is not a Playwright page method. Replace it with page.screenshot() or locator.screenshot().

The browser executable is missing

Run npx playwright install. In a restricted CI image, install the browser during image creation and ensure the process has permission to read its cache.

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.

Navigation times out

Check the URL, proxy and DNS settings. A page can remain busy because of analytics or streaming requests; wait for a specific ready selector instead of requiring networkidle. Increase the timeout only after fixing an actual slow dependency.

The screenshot is blank or incomplete

Wait for the visible content, confirm that the page did not redirect to a login or bot-check screen, and inspect console and network errors. For full-page captures, verify that lazy content is loaded before the call.

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

An element screenshot fails

Use a locator that matches exactly one intended element, wait for it to be visible, and check whether a modal or sticky layer covers it. For a scrollable element, capture the container’s visible area or implement a deliberate scrolling routine.

Visual tests differ on every run

Freeze animation, mask dynamic regions, use deterministic data, and keep browser, operating system, viewport and scale consistent. Do not treat a baseline generated on one host as universally portable.

The output directory does not exist

Playwright can write the file only when its parent directory exists. Create it first with mkdir -p artifacts (or the equivalent in your build script).

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. A single GET request returns PNG, JPEG, WebP or PDF. Before capture it accepts cookie and consent banners 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.

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

One-call cURL example

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 parameters. It supports full-page and CSS-selector captures, dark mode, 12 device presets or custom viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, pre-capture clicks, waits, ad/tracker/request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan. If you want to avoid installing and maintaining a browser, create a free ScreenshotNeo account.

Choosing the right capture method

Need Best fit
One local browser capture with custom interaction Playwright script and page.screenshot()
One element after actionability checks locator.screenshot()
Repeatable visual regression Playwright Test with stable baselines
One-off terminal capture Playwright CLI
Remote capture, cleanup of consent UI, PDFs or agent access ScreenshotNeo API or MCP server

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.