Launch Playwright’s Chromium browser, navigate to a page, then call page.screenshot(). Chromium runs headlessly by default, so a basic capture needs no special headless flag.
Capture a page with Playwright and Chromium
Install Playwright and its Chromium browser, then save a screenshot with this runnable JavaScript example:
As an Amazon Associate I earn from qualifying purchases.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch(); // Headless by default
try {
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
} finally {
await browser.close();
}
})();
Save it as screenshot.js and run node screenshot.js. The resulting screenshot.png is a viewport capture. The essential call is await page.screenshot({ path: 'screenshot.png' });; the surrounding steps launch Chromium, open a page, and navigate to the URL. See Playwright’s Page screenshot API and browser documentation.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Install the browser if needed
Install the Playwright package in your project and install its browser binaries. For headless-shell-only installations, Playwright documents npx playwright install --with-deps --only-shell. Browser build and installation details can change between Playwright releases; consult the browser documentation for the version installed in your project.
#1 Best Overall
- 【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.
Choose viewport or full-page capture
By default, the screenshot contains the current viewport, not the entire scrollable document. Set fullPage: true to capture the full page:
await page.screenshot({ path: 'full-page.png', fullPage: true });
Use viewport capture when you need the visible screen at a specific point in a page. Use full-page capture for a long document or page overview. Full-page output can be substantially taller than a viewport image.
Rank #2
- QHD Resolution (2560 x 1440) has 1.7 times the pixel density of Full HD for incredibly detailed pinsharp images
- HDR10 provides brighter highlights and nuanced shadow for added depth - making every scene feel more vivid and realistic
- The 180Hz refresh rate minimizes lag for gameplay with ultra-smooth action. Plus, the 1ms response time helps capture your moves in real-time, allowing you to react fast for gaming precision
- AMD FreeSync reduces choppiness, screen lag and image tearing, ensuring that your fast-paced, complex in-game action is stable with minimal stutter
- Ergonomic stand allows for tilt, pivot and height adjustments to maximize gaming comfort
Control output format, quality, and scale
Playwright supports PNG, JPEG, and WebP screenshots. PNG is the default; when saving to a path, Playwright can infer the format from the filename extension.
- PNG: Default format. The quality setting does not apply.
- JPEG: Specify
type: 'jpeg'and optionally aqualityvalue. The documented default quality is 80. - WebP: Specify
type: 'webp'and optionally aqualityvalue. The documented default is 100, which is lossless.
await page.screenshot({
path: 'page.webp',
type: 'webp',
quality: 85,
scale: 'css'
});
scale: 'css' creates one image pixel per CSS pixel. scale: 'device' uses device pixels and may create larger, high-DPI images; it is the documented default. Pick the scale according to whether the output should match CSS layout dimensions or retain device-pixel detail.
Rank #3
- Smooth motion: 240Hz refresh rate and fast 0.5ms response time provide crisp visuals and fluid movement with less input lag.
- Seamless gaming: FreeSync Premium and HDMI VRR eliminate tearing for smooth, responsive PC and console gameplay.
- Fast IPS: Faster 0.5ms response with excellent color accuracy across wide IPS viewing angles.
- Rich color: 99% sRGB color coverage delivers vivid, detailed imagery with strong accuracy.
- Eye comfort: TÜV Rheinland 3‑star certified display lowers blue light while preserving color quality.
Save the image or use it in memory
Providing path writes the image to disk. Without path, page.screenshot() returns an image buffer instead:
const image = await page.screenshot();
// Pass image to code that accepts a Buffer, or write it yourself.
This is useful when a script needs to upload the image, attach it to a report, or process it without first choosing a screenshot path in the API call.
Rank #4
- 27” 240Hz 1500R Curved FHD 1080P Gaming Monitor for Game Play.
- Prioritizes Gaming Performance: Up to 240Hz high refresh rate, more immersive 1500R Curvature, FreeSync, MPRT 1ms Response Time, Black Level adjustment(shadow booster), Game Modes Preset, Crosshair.
- Cinematic Color Accuracy: 130% sRGB & DCI-P3 95% color gamut, 4000:1 contrast ratio, 300nits brightness, HDR, Anti-flicker; Anti-Glare.
- Plug & Play Design: HDMI & DP1.4 & Audio Jack(No built-in speakers), durable metal stand, tilt -5°~15, VESA 100*100mm compatible.
- Warranty: Money-back and free replacement within 30 days, 1-year quality warranty and lifetime technical support. Pls contact SANSUI service support first if any product problem.
Make captures more repeatable
For stable captures, reduce movement and control the browser environment. The screenshot API offers animations: 'disabled' to disable CSS animations, transitions, and Web Animations during capture. Finite animations are fast-forwarded; infinite animations are canceled to their initial state for the screenshot. Playwright resumes animations afterward.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsawait page.screenshot({
path: 'stable.png',
animations: 'disabled',
style: '*, *::before, *::after { caret-color: transparent !important; }'
});
The optional style value injects CSS for the capture, letting you hide or alter dynamic content when appropriate. Screenshots can still differ across operating systems, browser versions, settings, hardware, power sources, and headless modes. For visual baselines, create and compare images in the same environment. Playwright explains these sources of variation in its visual comparisons guide.
Best Value
- 1800R curve monitor the curved display delivers a revolutionary visual experience with a leading 1800R screen curvature as the images appear to wrap around you for an in depth, immersive experience
- Hdmi, VGA & PC audio in ports
- High refresh rate 75Hz.Brightness (cd/m²):250 cd/m2
- Vesa wall mount ready; Lamp Life: 30,000+ Hours
- Windows 10 Sceptre Monitors are fully compatible with Windows 10, the most recent operating System available on PCs.Brightness: 220 cd/M2
Direct screenshots versus visual assertions
Use page.screenshot() when you need an image file or buffer. For automated visual regression tests, Playwright Test provides expect(page).toHaveScreenshot(). It waits until two consecutive screenshots match and then compares the result with an expected snapshot. Screenshot assertions are for the Playwright Test runner, rather than a replacement for the ordinary screenshot API.
Common problems and fixes
- No image appears on disk: Check that the script reached the screenshot call and that the process has permission to write to the selected directory. Use an explicit path if the current working directory is unclear.
- Only the visible area is captured: This is the default. Pass
fullPage: trueto capture the full scrollable page. - The screenshot looks soft or is unexpectedly large: Check the
scaleoption. The defaultdevicescale uses device pixels;cssgives one output pixel per CSS pixel. - Output format or quality is unexpected: Confirm the path extension or set
typeexplicitly. Quality affects JPEG and WebP, not PNG. - Captures differ between runs or machines: Disable animations when appropriate and keep the operating system, Playwright/browser version, settings, and execution environment consistent.
- Chromium is missing or the requested installation is too large: Install the browser build required by your Playwright version. The documented headless-shell-only command is
npx playwright install --with-deps --only-shell; check the browser docs before choosing an installation mode.
Or skip the browser setup
For a one-request screenshot without managing Playwright or Chromium, ScreenshotNeo accepts a URL and returns an image or PDF. Its screenshot API can remove cookie and consent banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. ScreenshotNeo also provides an MCP server with screenshot tools for AI agents.
Example cURL request (see the ScreenshotNeo API documentation):
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutecurl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for free.
Frequently Asked Questions
Does Playwright launch Chromium headlessly by default?
Yes. Playwright documents Chromium as headless by default. Its regular Chromium build and headless shell are separate options, and browser behavior can vary by Playwright release.
Can I get a screenshot without writing a file?
Yes. Omit the path option; page.screenshot() returns a buffer.
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.




