October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Take a Screenshot in Chromium with Playwright

A practical guide to saving screenshots from Chromium with Playwright, from viewport and full-page captures to element shots and visual test baselines.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright’s Chromium browser, open a page, then call page.screenshot(). Set path to save the image; use fullPage: true for the full scrollable page rather than only the visible viewport.

Take and save a Chromium screenshot

Install Playwright in your Node.js project, then run this example. It launches Chromium, navigates to a URL, saves a PNG, and closes the browser even if navigation or capture fails.

As an Amazon Associate I earn from qualifying purchases.

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

Run it with Node.js. The path is relative to the current working directory unless you provide an absolute path. The minimal launch-and-capture pattern is shown in the Playwright Page API; see also the migration guide.

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

Choose what to capture

Visible viewport

By default, page.screenshot() captures the viewport currently visible in the page. This is usually the right choice for a browser-sized snapshot.

#1 Best Overall
HP Chromebook 14 Laptop, Intel Celeron N4120, 4 GB RAM, 64 GB eMMC, 14" HD Display, Chrome OS, Thin Design, 4K Graphics, Long Battery Life, Ash Gray Keyboard (14a-na0226nr, 2022, Mineral Silver)
  • FOR HOME, WORK, & SCHOOL – With an Intel processor, 14-inch display, custom-tuned stereo speakers, and long battery life, this Chromebook laptop lets you knock out any assignment or binge-watch your favorite shows..Voltage:5.0 volts
  • HD DISPLAY, PORTABLE DESIGN – See every bit of detail on this micro-edge, anti-glare, 14-inch HD (1366 x 768) display (1); easily take this thin and lightweight laptop PC from room to room, on trips, or in a backpack.
  • ALL-DAY PERFORMANCE – Reliably tackle all your assignments at once with the quad-core, Intel Celeron N4120—the perfect processor for performance, power consumption, and value (2).
  • 4K READY – Smoothly stream 4K content and play your favorite next-gen games with Intel UHD Graphics 600 (3) (4).
  • MEMORY AND STORAGE – Enjoy a boost to your system’s performance with 4 GB of RAM while saving more of your favorite memories with 64 GB of reliable flash-based eMMC storage (5).
await page.screenshot({ path: 'viewport.png' });

Full scrollable page

Set fullPage: true to capture the page beyond the visible viewport.

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

One element

Use a locator’s screenshot() method to save a specific element, such as a header or card, instead of the entire page.

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

Locator-based capture is covered in the Playwright screenshot guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
ASUS 2026 15" FHD IPS Chromebook, Intel Processor Up to 2.80GHz, 4GB DDR4, 128GB Storage, HDMI, Super-Fast WiFi, Chrome OS, Pastel Silver (Renewed)
  • Intel Processor Up to 2.80GHz, 4GB DDR4, 128GB Storage
  • 15" FHD IPS Display, Intel UHD Graphics
  • 1x USB Type C, 1 x USB Type A, 1x Headphone/Microphone Combo Jack, HDMI
  • Fast WiFi and Bluetooth, Integrated Webcam
  • Chrome OS, AC Charger Included, Pastel Silver

A clipped rectangle

Pass a clip rectangle when you need a specific region. Its x and y coordinates identify the start of the rectangle; width and height set its size.

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

Choose the file format and screenshot options

Playwright supports PNG, JPEG, and WebP screenshots. It can infer the format from the filename extension, or you can set type explicitly. Without a path, the call returns an image buffer instead of writing a file.

const image = await page.screenshot({ type: 'jpeg' });

Other useful options include:

  • scale: 'css' or scale: 'device' to choose whether output dimensions follow CSS pixels or device pixels.
  • mask to cover matched locators in the output.
  • caret: 'hide' to hide the text caret.
  • animations: 'disabled' to disable animations for the capture.
  • omitBackground: true to produce a transparent background where supported. JPEG does not support omitted backgrounds.
  • style to apply a stylesheet during capture.

Consult the screenshot API reference for the complete option definitions and current behavior.

Rank #3
Lenovo Chromebook m 14" - Everyday Laptop - Google Gemini - MediaTek Kompanio 540 CPU - 14" WUXGA IPS Display - 8GB RAM - 64GB UFS Storage - Integrated Arm Mali-G57 MC2 GPU - Cosmic Blue
  • YOUR DAY SIMPLIFIED – Enjoy crisp calls, vibrant views, and real connection. The Lenovo Chromebook m 14” laptop features a stunning WUXGA 16:10 screen, a full set of ports, and a lightweight yet tough, military-grade build.
  • BRILLIANTLY IMMERSIVE – The vibrant WUXGA 1920x1200 display lets you see, hear, and create your world in thrilling new ways. Audio that's tuned with MaxxAudio delivers rich, balanced sound that pulls you deeper into every scene, playlist, and project.
  • TOUGH, LIGHT, READY FOR LIFE – Carry with confidence. At just under 3lbs, the Chromebook m 14” laptop is easy to handle and reinforced with military-grade durability to withstand daily bumps, drops, and spills.
  • LOOK SHARP STAY SECURE – Take charge of your privacy with the webcam’s physical privacy shutter. Open it confidently for video calls or livestreams and close it securely when you’re done, hassle-free.
  • CONNECT MORE TO DO MORE – Switch between devices and displays effortlessly while collaborating, studying, and sharing your screen. The built-in USB-C, USB-A, and HDMI ports let you charge, connect and present dongle-free.

Make capture timing reliable

A screenshot records the page state when the capture occurs. If the page depends on asynchronous content, wait for a meaningful condition before taking the image rather than assuming navigation alone means every visual element has finished loading. For example, wait for a key locator your page renders:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.goto('https://example.com');
await page.locator('main').waitFor();
await page.screenshot({ path: 'ready.png' });

Use a selector that is specific to the content you expect. A generic wait can hide a slow or failed page rather than making the capture correct.

Use screenshots for visual regression tests

For Playwright Test visual baselines, use expect(page).toHaveScreenshot() rather than comparing manually saved files. The assertion waits for two consecutive screenshots to match, then compares the latest capture with the expected baseline. This feature belongs to the Playwright Test runner.

Rank #4
Acer Chromebook Plus 514 Laptop, 14" Touchscreen, Intel i3-N355, 8GB/512GB
  • THIN & DURABLE DESIGN - Boasting a thin and light design, the Acer Chromebook Plus 514 is designed to keep you productive and entertained from anywhere. It weighs only 3.09 lbs and meets MIL-STD 810H military standards for reliable performance in harsh conditions. With long battery life and fast charge technology, it lets you work, study, watch, and stay connected without interruptions. It is perfect for commuting, travel, or working on the go
  • AI-POWERED CREATIVITY - The laptop has AI-powered Google and Adobe tools to turn inspiration into reality faster. Its Gemini AI simplifies organizing creative drafts and optimizing materials. The dedicated Quick Insert key creates high-resolution images and offers writing assistance for seamless creativity. Unlock Google AI Pro for 12 months with this Chromebook Plus purchase. Experience Gemini Advanced, NotebookLM, 5TB of cloud storage, and boost productivity with Gemini integrated into Gmail, Docs, and more
  • POWERFUL PERFORMANCE - Powered by the 8-Core Intel Core i3-N355 Processor with Intel Graphics, it ensures smooth performance for everyday tasks. It features 8GB LPDDR5X RAM for fast, efficient multitasking and 512GB SSD, offering ample space for files, apps, media, and more, delivering fast storage access and reduced load times
  • EXCELLENT VISUAL - Featuring a 14" WUXGA (1920x1200) IPS touchscreen with 300-nit brightness, this device delivers vibrant visuals and responsive touch functionality. It supports expanding the workspace with 3 external monitors via HDMI (max 4K@30Hz) or USB Type-C (max 4K@60Hz), without a docking station. Plus, a 1080p webcam with a privacy shutter to prevent unauthorized viewing meets daily video chat or conference needs
  • RICH CONNECTIVITY OPTIONS - Equipped with 2x USB-C 3.2 Gen 1, 2x USB-A 3.2 Gen 1, HDMI 1.4, and a headphone/microphone combo jack. It features Wi-Fi 6E and Bluetooth 5.3 for blazing-fast wireless speeds and seamless device pairing, plus a white backlit keyboard that lets you work comfortably in any lighting
import { test, expect } from '@playwright/test';

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

Keep baseline creation and comparison in the same environment where possible. Browser version, operating system, settings, hardware, power source, and headless mode can all affect rendering. Playwright’s visual comparisons guide explains the source of screenshot differences and baseline workflow.

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 only contains the top of the page: the default capture is the viewport. Set fullPage: true when you need the whole scrollable document.
  • No file appears: check that the script completed, that the destination directory exists, and that you are looking relative to the process’s current working directory. Set an absolute path to remove ambiguity.
  • The capture is blank or incomplete: wait for the page’s relevant content or selector before calling screenshot(); a navigation call does not guarantee that every application-specific element has rendered.
  • The element capture fails: confirm the locator matches the intended element and that it is present before calling locator.screenshot().
  • Visual tests fail on another machine: rendering can vary with environment and browser settings. Generate and compare baselines under consistent conditions.
  • A transparent background is missing: use a format that supports omitted backgrounds; JPEG does not support omitBackground.

Or skip the browser setup

If you need a screenshot from an API rather than running Chromium yourself, ScreenshotNeo returns an image or PDF from one GET request. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; bot checks, blank pages, and failed loads are not billed. It also provides an MCP server so AI agents can take screenshots.

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

For example, save a WebP screenshot with cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Its free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for the free plan.

Frequently Asked Questions

Can I get screenshot bytes instead of saving a file?

Yes. Omit the path option; page.screenshot() returns a buffer.

Does Playwright capture the full page by default?

No. It captures the visible viewport unless you set fullPage: true.

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.

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

Leave a Reply

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

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
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.