Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
In JavaScript or TypeScript, save a Playwright screenshot with await page.screenshot({ path: 'screenshot.png' });. Set fullPage: true for the entire scrollable page, call locator.screenshot() for one element, or omit path when you need the image as bytes in memory.
This guide shows a complete browser-based workflow, explains the options that affect fidelity and stability, and covers common failures. At the end, ScreenshotNeo provides a one-request alternative when you do not want to maintain browser setup.
Set up Playwright
Install Playwright in a Node.js project, then install its browser binaries:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
npm install -D playwright
npx playwright install
Create a script that starts a browser, opens a page, captures an image, and closes the browser even if an error occurs:
#1 Best Overall
- 【1080P HD High Quality】Capture resolution up to 1080p for video source and it is ideal for all HDMI devices such as PS4, PS3, Xbox One, Xbox 360, Wii U, DVDs, DSLR, Camera, Security Camera and set top box. Note: Video input supports 4K30/60Hz and 1080p120/144Hz. Does not support 4K120Hz/144Hz. Output supports up to 2K30Hz.
- 【Plug and Play】No driver or external power supply required, true PnP. Once plugged in, the device is identified automatically as a webcam. Detect input and adjust output automatically. Won't occupy CPU, optional audio capture. No freeze with correct setting.
- 【Compatible with Multiple Systems】suitable for Windows and Mac OS. High speed USB 3.0 technology and superior low latency technology makes it easier for you to transmit live streaming to Twitch, Youtube, Facebook, Twitter, OBS, Potplayer and VLC.
- 【HDMI LOOP-OUT】Based on the high-speed USB 3.0 technology, it can capture one single channel HD HDMI video signal. There is no delay when you are playing game live.
- 【Support Mic-in for Commentary】Rybozen capture card has microphone input and you can use it to add external commentary when playing a game. Please note: it only accepts 3.5mm TRS standard microphone headset.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'screenshot.png' });
} finally {
await browser.close();
}
})();
The path is relative to the process’s current working directory unless you provide an absolute path. Playwright creates the image file after the screenshot completes.
Choose the capture scope
Viewport screenshot
The basic call captures what is currently visible in the browser viewport:
await page.screenshot({ path: 'viewport.png' });
Use this for a browser-state snapshot, a bug report, or a fixed-size visual test. The viewport dimensions come from the page or context configuration, so set them explicitly when consistent output matters.
Full-page screenshot
Pass fullPage: true to capture the page’s full scrollable height instead of only the visible area:
await page.screenshot({ path: 'full-page.png', fullPage: true });
Full-page mode is useful for documenting long documents and checking layout below the fold. It can produce a very tall image; for large pages, consider whether a PDF or a clipped region is a better deliverable.
One element
Capture a specific element through a locator:
await page.locator('.header').screenshot({ path: 'header.png' });
The locator must resolve to the intended element. Prefer a stable selector such as a test identifier, semantic attribute, or component class rather than a generated class name.
Python uses the corresponding snake-case argument style:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →page.locator('.header').screenshot(path='header.png')
A clipped rectangle
Use clip when you need a rectangle in page coordinates rather than a DOM element:
await page.screenshot({
path: 'chart-area.png',
clip: { x: 120, y: 240, width: 900, height: 500 }
});
Clipping is useful for a canvas, chart, or fixed region whose selector is inconvenient. Make sure the rectangle has positive dimensions and lies within the rendered page.
Rank #2
- 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
- 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
- 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
- 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
- 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
Save to disk or keep the image in memory
Write a file
Set path to write the result directly:
await page.screenshot({ path: 'artifacts/home.webp', type: 'webp' });
Use a directory that your process can write to. In CI, create the artifact directory before the test or use the test runner’s configured output directory.
Return bytes
Omit path when the next operation is image processing, visual comparison, or an upload:
const buffer = await page.screenshot({ type: 'png' });
await uploadToStorage(buffer);
The returned value is a buffer in Node.js. Python likewise returns bytes when path is omitted:
image_bytes = page.screenshot(type='png')
process_image(image_bytes)
Keeping the result in memory avoids a temporary file, but large full-page captures consume corresponding memory.
Control image format and output
| Option | Purpose | Practical consideration |
|---|---|---|
type |
Selects the image format supported by the screenshot API. | PNG is lossless; JPEG and WebP can reduce size when lossy compression is acceptable. |
quality |
Controls lossy-image quality where applicable. | It has no useful effect on formats that do not use lossy quality settings. |
fullPage |
Captures the full scrollable page. | Long pages create tall files and may expose content that is not visible in the initial viewport. |
clip |
Limits capture to an x, y, width, and height rectangle. |
Use page-coordinate values and positive dimensions. |
animations |
Allows or disables CSS and Web Animations during capture. | Disable or control animations when pixel-stable output matters. |
caret |
Hides or preserves the text caret. | Hide it for deterministic documentation; preserve it when documenting an editing state. |
mask and maskColor |
Covers selected locators before capture. | Mask changing, private, or irrelevant regions so comparisons focus on layout. |
omitBackground |
Allows transparent output. | Useful for assets that will be composited elsewhere. |
scale |
Chooses CSS-pixel or device-pixel sizing. | Pick deliberately when comparing screenshots from different display densities. |
Screenshot options can evolve with Playwright releases. Check the API reference for the version installed in your project before relying on a newly added option.
Make captures deterministic
Wait for the page state you need
A screenshot records the current rendered state, not an abstract page definition. Navigate to the target URL, wait for the content your test requires, and only then capture. Waiting for a selector is more precise than taking an arbitrary early screenshot:
await page.goto('https://example.com/dashboard');
await page.locator('[data-testid="dashboard"]').waitFor();
await page.screenshot({ path: 'dashboard.png' });
If the page contains transitions or continuously moving content, disable or otherwise control animations with the screenshot options. For visual tests, mask timestamps, rotating promotions, avatars, and other intentionally changing regions.
Set viewport and scale explicitly
Responsive layouts change with viewport width and height. Configure the viewport before navigation when a screenshot is compared over time. Use scale consistently so a run on a high-density machine does not unexpectedly change pixel dimensions.
Capture dynamic graphics
Playwright can capture rendered canvas and chart content. Wait until the component has drawn its data, then use an element locator or a clip rectangle around it. If a chart animates into place, wait for its stable state or disable the animation before taking the image.
Rank #3
- 4K60 Capture: Record in cinematic quality with crisp detail and vivid colors
- HFR Support: Play and capture in 1440p120 or 1080p240
- HDR10 Support: Capture brilliant HDR content with tone mapping on Windows
- Cross-Platform Compatible: Works with PS5, Xbox Series X/S, Switch 2, and more
- Analog Audio In: Capture in-game chat or commentary with 3.5mm input
Reusable JavaScript examples
Viewport, full page, element, and bytes in one script
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'viewport.png', type: 'png' });
await page.screenshot({ path: 'full-page.webp', fullPage: true, type: 'webp', quality: 85 });
await page.locator('header').screenshot({ path: 'header.png' });
const bytes = await page.screenshot({ type: 'png' });
console.log(`Captured ${bytes.length} bytes`);
} finally {
await browser.close();
}
})();
TypeScript variant
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto('https://example.com');
await page.screenshot({ path: 'page.png', fullPage: true });
} finally {
await browser.close();
}
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting
The browser executable is missing
Symptom: launch fails with an error that a browser executable cannot be found.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchFix: run npx playwright install in the same environment where the script runs. In a container or CI job, include that installation step in the image or job setup.
The screenshot is blank or incomplete
Cause: capture happened before navigation or application rendering finished.
Fix: await page.goto(), wait for a selector that proves the required content is present, and then capture. For a chart or canvas, wait for the drawing code’s visible result rather than only for the document load event.
Full-page output is unexpectedly short
Cause: the page has not expanded to its final scrollable height, or content appears only after interaction.
Fix: wait for the content that controls page height, perform the required interaction, and then use fullPage: true. Confirm that the locator or application state represents the complete document.
An element screenshot fails
Cause: the selector matches nothing, matches the wrong element, or the element is not in a capturable rendered state.
Fix: use a stable locator, wait for it, and verify the selector in the same page state. If the target is inside a frame, locate it through the frame before calling screenshot().
Visual diffs change between runs
Cause: animations, carets, timestamps, rotating content, fonts, or device-pixel scaling differ.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #4
- High-Quality Video Capture, 4K HDMI Capture Card Ready: Capture smooth and vibrant video with this 4K HDMI capture card, engineered for gamers and content creators who demand crisp 1080P 60FPS video quality. Whether you're streaming to Twitch or recording gameplay for YouTube, your footage will look professional and detailed
- Plug-and-Play USB Capture Card, No Drivers Needed: Designed as a USB capture card for streaming, this device works instantly out of the box, just plug into your PC or laptop and start capturing. Fully compatible with popular software like OBS Studio, Streamlabs, and XSplit, making setup quick and stress-free for beginners and pros alike
- Universal Compatibility PS5, Xbox, Switch & More: Stream or record gameplay from virtually any HDMI-enabled device including Nintendo Switch, PS5, Xbox Series X, DSLR cameras, and PCs. The video capture card for gaming supports seamless passthrough so you can play without lag while your audience watches every frame in real time
- Low-Latency Performance for Smooth Streaming: This capture card for streaming minimizes delay between gameplay and broadcast, so you get reliable, low-latency capture that works well for competitive gaming, live broadcasts, and podcast sessions. Suitable for those building their channel with high-quality, engaging content
- Compact & Portable Design for Content Creators: Lightweight and portable, this USB 3.0 capture card works well for creators who travel or switch gaming setups often. Throw it in your bag and stream or record wherever you are, at home, events, LAN parties, streaming or studio sessions
Fix: control animations, choose a consistent caret and scale, mask volatile locators, and use the same viewport and browser environment for each comparison.
The output file is too large
Fix: capture only the needed element or clip rectangle, choose WebP or JPEG when lossy compression is acceptable, and use an appropriate quality value. A full-page PNG preserves detail but can be disproportionately large.
Performance, reliability, and cost decisions
Browser screenshots include the cost of launching a browser, loading the page, executing its JavaScript, and rendering resources. Reuse a browser process when taking several screenshots, while creating isolated pages or contexts for separate jobs. Keep waits specific: waiting for a meaningful selector usually finishes sooner and is more reliable than adding a long fixed delay.
For repeatable visual testing, standardize viewport, scale, format, animation handling, masking, and the page state that precedes capture. Store bytes directly when an upload or comparison follows immediately; write files when humans or CI systems need downloadable artifacts.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. It is the first alternative to try when you want a single request instead of managing Playwright browsers: it removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; and its response identifies the page verdict and billing status with X-Page-Verdict and X-Billed headers.
ScreenshotNeo accepts PNG, JPEG, WebP, or PDF output. Its 63 options include full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector/delay/network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. The parameter names used by other screenshot APIs also work, which can simplify migration.
It also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
One-call cURL request
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python request
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 request
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 request options and response details. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account to begin.
Free tools Windows power users keep installed
One-click scans. No signup required.
Frequently Asked Questions
Does Playwright support screenshot code outside JavaScript and Python?
Yes. The official Playwright guide also documents equivalent screenshot APIs for Java and .NET; use the syntax for the language binding installed in your project.
Should I use a screenshot file or bytes?
Use a file when a person or CI system needs an artifact. Omit path and keep the returned bytes when the next step is processing, comparison, or upload.
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.

