DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
browser automation

How to Automatically Take Screenshots with Browser Automation

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

Use a real browser, wait for the page state you need, then call the browser’s screenshot API. Playwright and Puppeteer can save viewport, full-page, clipped, and element images from repeatable scripts. Reliable automation depends on fixed viewport settings, explicit waits, controlled animations, stable selectors, and predictable artifact paths—not on calling screenshot() immediately after navigation.

Choose the capture workflow first

Decide what the image must prove before writing code. A viewport screenshot records exactly what a user sees at a chosen window size. A full-page screenshot captures the entire scrollable document. An element screenshot isolates a component such as a header, invoice, chart, or product card. A clipped screenshot records a rectangle, which is useful for a known region but less resilient than a semantic element selector.

  • Viewport: responsive-layout checks and review artifacts.
  • Full page: complete documentation of a long page.
  • Element: component-level tests and focused evidence.
  • Clip: pixel-bounded regions whose coordinates are stable.

Keep these artifact types separate in CI. A full-page image can hide a broken fold layout, while a viewport image cannot show content below the fold.

Playwright: a complete automated screenshot

Install Playwright in a Node.js project, then install its browser binaries:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Remote Control for TikTok,Wireless Remote Camera Control Shutter with Zoom for iPhone, Front Rear Camera Switch,Page Turner for E-Book APP, Phone Remote, Scrolling Ring for TIK Tok (Black/Black)
  • 【Zoom In/Out & Front Rear Camera Switch】This remote camera shutter features wireless zoom control—It has zoom feature can wirelessly zoom in and out on phone camera when taking photos and videos both in system camera and tiktok app camera. Press '+' button zoom in,Press '-' button zoom out. Noted: Some Front cameras do not have zoom function
  • 【Multi-Function: Tiktok Short Video & E-Book Control】More than a photo remote for Android/iPhone, this upgraded remote lets you scroll & control tiktok app (play/pause, double-tap to like),Adjust volume & capture screenshots hands-free and turn e-book pages (compatible with most e-reader apps; not for Kindle devices)
  • 【Universal Compatibility&Stable Wireless Connection 】This multi-device remote works flawlessly with iOS 14.8+ and Android 11+ smartphones.Featuring advanced wireless technology, it maintains a stable 33-foot range - perfect for hands-free vlogging, group photos, and live streaming.
  • 【Rechargeable & Long-Lasting Battery】Enjoy uninterrupted shooting with a high-capacity rechargeable battery that supports 2,000+ operations per charge. The USB-C charging ensures fast power-ups, while the ultra-lightweight (28g) design slips easily into your pocket or bag—perfect for travel, vlogging, and daily use.
  • 【Detachable Lanyard & Hands-Free Convenience】Includes a lanyard to secure the remote to your wrist or bag. Ideal for hands-free shooting, live streaming, and content creation!
npm install -D playwright
npx playwright install

Create the output directory before writing files. This script fixes the viewport, waits for network activity to settle, and writes three different artifacts:

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

(async () => {
  fs.mkdirSync('artifacts', { recursive: true });
  const browser = await chromium.launch();
  const page = await browser.newPage({
    viewport: { width: 1440, height: 900 },
    deviceScaleFactor: 1
  });

  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await page.screenshot({ path: 'artifacts/home.png' });
  await page.screenshot({ path: 'artifacts/home-full.png', fullPage: true });
  await page.locator('header').screenshot({ path: 'artifacts/header.png' });

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

The documented Playwright page API supports ordinary file capture, full-page capture, buffers, and locator or element screenshots. The screenshots guide also covers command-line capture, PNG/JPEG/WebP output, and high-resolution device scaling.

Wait for the state that matters

networkidle is only one signal. A single-page app may finish navigation while fonts, images, or API data are still changing. Wait for a meaningful selector or application condition:

await page.goto('https://example.com/dashboard', { waitUntil: 'domcontentloaded' });
await page.locator('[data-testid="report-ready"]').waitFor({ state: 'visible' });
await page.screenshot({ path: 'artifacts/report.png', fullPage: true });

For lazy-loaded pages, scroll deliberately before a full-page capture so content that appears only after intersection events is present:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.goto('https://example.com/catalog', { waitUntil: 'domcontentloaded' });
await page.evaluate(async () => {
  await new Promise(resolve => {
    let y = 0;
    const step = 600;
    const timer = setInterval(() => {
      window.scrollBy(0, step);
      y += step;
      if (y >= document.body.scrollHeight) {
        clearInterval(timer);
        window.scrollTo(0, 0);
        resolve();
      }
    }, 100);
  });
});
await page.screenshot({ path: 'artifacts/catalog-full.png', fullPage: true });

Prefer a selector that represents readiness over an arbitrary sleep. Use a short delay only when the application has no observable state you can wait for.

Element, clipped, masked, and transparent captures

Locator screenshots follow the element’s current bounding box and are generally more robust than hard-coded coordinates:

await page.locator('.invoice').screenshot({ path: 'artifacts/invoice.png' });

For a fixed rectangle, use clip. JPEG and WebP quality, background omission, masking, and animation controls are available through the Page API:

await page.screenshot({
  path: 'artifacts/region.webp',
  type: 'webp',
  quality: 82,
  clip: { x: 120, y: 180, width: 900, height: 500 },
  omitBackground: true,
  animations: 'disabled',
  mask: [page.locator('[data-private]')]
});

Mask timestamps, advertisements, account names, and other changing or sensitive regions before storing artifacts. Use scale: 'css' when you need one output pixel per CSS pixel; device scaling produces a higher-resolution image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Nonbliep 2 Pack Wireless Controller for Nintendo Switch 2/1 Lite/OLED and PC, with Bluetooth, Turbo, Gyro Axis, Dual Vibration, and Screenshot, Compatible with Steam and Switch 2/1
  • 🎮【Compatible with Nintendo Switch】PERFECT COMPATIBILITY: Wireless controller is fully compatible with Nintendo Switch/Switch 2/Switch Lite/ Switch OLED /Windows PC and perfect support Nintendo and video games.(Note: This function can be used to wake up the original Switch, but not the second generation.)
  • 🎮【ENHANCED GAMING EXPERIENCE】: Enjoy an immersive gaming experience with built-in dual motion motors and TURBO function. Choose from 3-level turbo speeds (8, 15, or 25 rounds/second) and the automatic shooting function for precision gameplay. The latest motion sensing technology and feedback technology ensures rapid response to movements.
  • 🎮【WIRELESS AND RELIABLE】: Our high-performance wireless technology ensures a reliable signal within 10 meters, with strong anti-interference capability. Equipped with 4 LEDs indicating functions and controller buttons, this controller also boasts an excellent dual analog joystick design for seamless gameplay.
  • 🎮【EXCELLENT HAND FEELING】: The wireless controller is built with ergonomic and lightweight construction, make it comfortable even for long hours of continuous play. The gamepad comes with non-slip design, which will never slip off even if your hand sweats during intense gameplay.
  • 🎮【Long battery life】: The switch pro controller f with 1000 MAH large capacity battery, but it just need 2-3 hours to charge fully. Switch controllers pro can run for 10 hours, make sure you can enjoy games longer without interruption.

Playwright visual assertions in CI

When the goal is regression detection rather than documentation, use Playwright’s screenshot assertions:

const { test, expect } = require('@playwright/test');

test('home page stays visually stable', async ({ page }) => {
  await page.setViewportSize({ width: 1440, height: 900 });
  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await expect(page).toHaveScreenshot('home.png', {
    animations: 'disabled',
    mask: [page.locator('.clock')]
  });
});

Playwright’s assertion workflow disables or controls animations as configured and waits for two consecutive screenshots to be identical before comparison. That reduces false failures caused by transitions, clocks, and late layout shifts. Review the visual comparisons documentation for baseline management and failure artifacts.

Puppeteer: the equivalent script

Puppeteer’s API is similarly direct. Install it with npm and save an ordinary page image plus an element image:

npm install puppeteer
const puppeteer = require('puppeteer');
const fs = require('fs');

(async () => {
  fs.mkdirSync('artifacts', { recursive: true });
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.setViewport({ width: 1440, height: 900, deviceScaleFactor: 1 });
  await page.goto('https://news.ycombinator.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'artifacts/page.png' });
  const element = await page.waitForSelector('body');
  await element.screenshot({ path: 'artifacts/body.png' });
  await browser.close();
})();

The official Puppeteer screenshot guide documents Page.screenshot() and ElementHandle.screenshot(). Use networkidle2 as a navigation hint, then wait for the specific content your page renders. For a full document, pass fullPage: true to page.screenshot().

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

Playwright or Puppeteer?

Both can navigate, select an element, and save a screenshot. Choose according to your project rather than image capability alone.

Decision point Playwright Puppeteer
Element selection Locator API with semantic and auto-waiting patterns Selectors and element handles
Capture types Viewport, full-page, locator, clip, mask, scale, PNG/JPEG/WebP Page and element screenshots, with explicit paths
Visual testing Built-in screenshot assertions and animation handling Use your chosen test and image-diff tooling
Best fit Teams already using Playwright Test or needing integrated visual assertions Projects standardized on Puppeteer and its browser automation API

Do not infer broader browser-coverage or performance differences from screenshot methods alone; validate those requirements against the versions and runtimes in your own project.

Make screenshots deterministic in CI

  1. Fix viewport and scale. Set width, height, and device scale factor explicitly so dimensions do not depend on the runner.
  2. Control fonts and assets. Wait for the application’s ready selector and, where relevant, verify that web fonts and critical images have loaded.
  3. Freeze motion. Disable animations and transitions for comparison captures. A moving carousel can produce a different image on every run.
  4. Mask volatility. Hide timestamps, rotating ads, personalized names, counters, and live data before saving or comparing.
  5. Use stable selectors. Prefer data-testid or semantic locators over generated CSS classes and coordinates.
  6. Separate artifacts. Store viewport, full-page, and element outputs with descriptive names and the commit or build identifier.
  7. Close the browser. Put cleanup in a path that also runs after failures so CI workers do not accumulate processes.

For authenticated pages, load test credentials through CI secrets, not source files. Avoid capturing real customer data; mask or use a seeded test account.

Performance, reliability, and cost decisions

A browser launch is expensive compared with a single page operation. Reuse one browser process and create isolated pages or contexts for a batch. Limit concurrency to what the CI runner’s CPU and memory can sustain; excessive parallelism causes timeouts and makes rendering less predictable. Capture only the image types you need: full-page images consume more memory and storage than a viewport or element image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Switch Controllers 2 Pack with Charging Dock, Switch 2 Controller for Nintendo Switch/Switch 2/Lite/OLED, Wireless Switch 2 Pro Controller with RGB/Wake up/6-Axis Gyro/Dual Vibration/Turbo/Screenshot
  • 【Multi Platform Compatible】This switch controllers is fully compatible with Nintendo Switch/Switch 2/Switch Lite/Switch OLED/Windows/PC/Android/iOS, No need to install any driver. Wide compatibility and lower latency, from fast-paced action titles to casual multiplayer games for a seamless gaming experience. all functions are fully usable, including: Dual Vibration, 6-Axis Gyroscope, Screenshot, Wake up, Hall effect buttons, Motion Sensor and Turbo.
  • 【Fast & Safe Charging Dock】The included charging dock ensures quick and reliable charging for 2 pack switch controllers and 4 joycon controllers(not with Switch 2 joycon). Built-in safety features prevent overcharging and overheating, keeping your gear protected.
  • 【Cool and Colorful RGB Lighting】This switch 2 pro controller has a built-in 6-axis gyroscope chip for precise motion control, It features 7 colors of RGB lighting (red, orange, yellow, green, cyan, blue, violet) and 4 light modes (dazzle, monochrome, monochrome breathing, monochrome breathing cycle). You can change the lighting colors and modes depending on the game genre or your personal preferences, Elevate your gaming atmosphere.
  • 【4 Level Vibration & Turbo Function】The switch 2 controller equipped with dual vibration motors with adjustable intensity (100%/75%/50%/Off), Experience true-to-life feedback from crashes and explosions. Supports customizable rapid-fire for A/B/X/Y and 7 other keys, with three adjustable speed levels. Perfect for shooting and action games, no more frantic button mashing.
  • 【Long Battery Life】JORREP switch controllers with 800mAh large capacity rechargeable battery, it just need 2-3 hours to charge fully. Switch controllers can run for 10 hours supports play-while-charging, ensures uninterrupted gameplay. Features low-battery alerts and auto-sleep after 5 minutes of inactivity.

Set navigation and assertion timeouts explicitly, retain the failing page screenshot and console logs, and retry only transient infrastructure failures. A retry cannot fix a selector that never appears or a page that always renders a CAPTCHA. For visual tests, review baseline changes as code changes: an updated font, browser version, operating-system rendering, or intentional CSS change can alter many pixels.

Troubleshooting common failures

Screenshot is blank or taken too early

Cause: navigation completed before the app rendered its data or the target was below a lazy-loading threshold. Fix: wait for a readiness selector, scroll to trigger lazy content, and capture only after the relevant images or component are present.

Element selector times out

Cause: the selector is unstable, hidden behind a login state, or the page failed to load. Fix: inspect the final URL and console, use a stable semantic or test-id selector, and verify the test account and feature flags.

Full-page image misses content

Cause: content loads on scroll or the page uses an internal scroll container. Fix: scroll the document first; for an internal container, capture that element or adjust the application state so all rows are rendered.

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

CI images differ on every run

Cause: animations, clocks, random data, fonts, or device-scale differences. Fix: set viewport and scale, disable motion, mask dynamic regions, seed test data, and keep browser dependencies consistent.

Browser cannot launch in a container

Cause: missing browser binaries or system libraries, or an incompatible sandbox configuration. Fix: run the framework’s browser-install command in the image, use the framework’s documented container setup, and preserve launch stderr in CI logs.

Request hangs or returns a bot challenge

Cause: the site blocks automation or requires an interactive challenge. Fix: do not attempt to defeat a CAPTCHA; use an authorized test environment, an API-provided fixture, or obtain permission from the site owner.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you need a clean image without maintaining browser workers. One GET request returns PNG, JPEG, WebP, or a PDF. Its capture flow accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and 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.
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 documentation for all parameters and response details. The same request in Python:

Rank #4
XPPen Mini Keydial ACK05 Wireless Shortcut Keyboard Bluetooth Programmable Express Remote Control with Dial & Customized Express Keys for Drawing Tablet PC MacBook Windows Images Video Editing
  • Wireless Connection: ACK05 wireless shortcut keyboard supports bluetooth 5.0 connection directly, which is Good Design Award 2023 Winners, providing you a more flexible and clean workspace. You can also connect it via a Bluetooth dongle or USB cable. Total three ways connection bring you stable and fast transmission, also can meet your different work scenarios
  • Please Note: If you do not download the driver, it can only be used as a regular shortcut keyboard. However, if you wish to customize the keys or program it, you must download the driver and configure it accordingly. If your device is an iPad or runs on iOS, after receiving the product, you need to download the "Shortcut Remote" app on your device in order to properly set up and use this product properly
  • Compact Size with Large 1000 mAh Battery: The Wireless Shortcut Remote features a thin profile and weighs only 75 g, easy for one hand to hold. With built-in 1000 mAh battery ensures the continuous working for about 300 hours. Ready to speed up your creation whenever you grab it
  • Customize up to forty Shortcuts: The Wireless Shortcut Remote has ten keys. You are allowed to customize four sets through the driver -- up to forty shortcuts. To switch between the sets, you only need to press a single key. Its capability to work with different applications makes itself a powerful productivity tool not only for creation, but also for study, work, and gaming
  • Anti-Ghosting Performance: The Mini Keydial features a new technology of Anti-ghosting for all ten keys, you can control with multi-keys at the same time, which will give you more customizable possibilities
import requests
r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

And 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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
require('fs').writeFileSync('shot.webp', data);

ScreenshotNeo includes full-page and selector captures, dark mode, 12 device presets or custom viewports, retina scale, PDF paper settings, custom CSS and JavaScript, pre-capture clicks, selector waits, delays or network-idle waits, ad and tracker blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, usage API, OpenAPI specification, and familiar parameter names for easier migration. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

Plan Included screenshots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is included on every plan. The service is useful when cookie banners, popups, chat widgets, failed-load billing, AI-agent access, or browser infrastructure are the constraints. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

FAQ

Can I capture only one CSS-selected component?

Yes. Playwright locators and Puppeteer element handles can capture a selected element after it is visible; ScreenshotNeo also supports element capture by CSS selector.

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

Should I use a delay instead of network idle?

Use an application-specific readiness condition first. A delay is a fallback for pages without an observable signal, not proof that every asset has settled.

What format should CI artifacts use?

PNG is the safest default for pixel comparisons. JPEG or WebP can reduce storage when exact lossless pixels are not required.

Frequently Asked Questions

Can browser automation capture a PDF as well as an image?

Yes. Playwright and Puppeteer can print pages through their PDF APIs, while ScreenshotNeo exposes PDF capture with paper size, margins, orientation, and page-range controls.

How do I avoid leaking secrets in screenshots?

Use dedicated test accounts, load credentials from CI secret storage, mask sensitive selectors, and restrict artifact retention and access.

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.

The Bottom Line

For code-controlled tests, launch Playwright or Puppeteer with fixed dimensions, wait for meaningful application state, control motion, and save explicit artifacts. If maintaining browsers is unnecessary, ScreenshotNeo supplies a one-call alternative with clean captures, non-billing for failed pages, and an MCP interface for AI agents.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.