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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use JavaScript browser automation to load the real page, apply temporary CSS or change the page state, then capture the result. With Playwright, pass capture-only CSS through page.screenshot({ style }); use page JavaScript when you need to click, open, remove, or annotate something before the shot. The examples below show how to choose the capture area, control output, and make captures more repeatable.

Choose screenshot-time CSS or page JavaScript

For visual changes that should affect only the image, Playwright’s screenshot style option is usually the cleanest approach. It applies a stylesheet while the screenshot is made, rather than changing the page’s persistent state. Playwright documents that these styles can hide dynamic elements and can apply inside Shadow DOM and inner frames. Playwright screenshots documentation

await page.goto('https://example.com');
await page.screenshot({
  path: 'styled.png',
  fullPage: true,
  style: `
    .cookie-banner, .chat-widget { display: none !important; }
    main { outline: 3px solid #6b5bff; }
  `,
});

This is runnable inside an existing Playwright script after creating a page. The selectors are examples, not selectors guaranteed to exist on a given site: inspect the page and replace them with selectors that match its markup. Use CSS for appearance-only changes such as hiding a banner, changing a background, or highlighting a region.

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

Use JavaScript before capture when the screenshot depends on interaction or state: opening a menu, clicking a tab, removing an element, adding an annotation, or waiting for client-side work to finish. The shot-scraper documentation demonstrates pre-capture JavaScript for setting styles, hiding elements, clicking links, and waiting for asynchronous work. shot-scraper documentation

Set up a complete Playwright JavaScript capture

Install Playwright and its Chromium browser in a Node.js project:

#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
npm install playwright
npx playwright install chromium

Save the following as capture.mjs and run it with node capture.mjs. It navigates to a target URL, waits for a meaningful page condition, applies screenshot-only CSS, and saves a full-page PNG. Change the URL and selectors for the site you are capturing.

import { chromium } from 'playwright';

const browser = await chromium.launch({ headless: true });
try {
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
  await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
  await page.locator('main').waitFor({ state: 'visible', timeout: 15000 });

  await page.screenshot({
    path: 'styled.png',
    fullPage: true,
    type: 'png',
    scale: 'css',
    style: `
      .cookie-banner, .chat-widget { display: none !important; }
      main { outline: 3px solid #6b5bff; }
      *, *::before, *::after { animation: none !important; transition: none !important; }
    `,
  });
} finally {
  await browser.close();
}

The main wait prevents the capture from proceeding before the primary content is visible, assuming the target page uses that element. Replace it with a reliable locator from the page. If the site requires client-side rendering or data loading, wait for the specific content or state the screenshot needs rather than assuming that navigation alone means it is ready.

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.

Change page state before the capture

For an interaction, run it after navigation and before page.screenshot(). For example, if the page has a button with an accessible name of “Menu,” open it as follows:

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
await page.getByRole('button', { name: 'Menu' }).click();
await page.getByRole('navigation').waitFor({ state: 'visible' });
await page.screenshot({ path: 'menu-open.png' });

Accessible locators are preferable when available because they express the user-facing control. For a one-off annotation or a known element removal, page JavaScript can alter the DOM directly, but that code depends on the target page’s structure:

await page.evaluate(() => {
  const note = document.createElement('div');
  note.textContent = 'Review this section';
  Object.assign(note.style, {
    position: 'fixed',
    top: '16px',
    right: '16px',
    zIndex: '2147483647',
    padding: '10px 14px',
    background: '#fff3a6',
    color: '#222',
    font: '14px sans-serif',
  });
  document.body.append(note);
});
await page.screenshot({ path: 'annotated.png' });

Keep in mind that DOM changes made through evaluate() modify the page in that browser context, while screenshot style is intended for capture-time presentation changes. Neither method changes the website for other visitors.

Choose what part of the page to capture

  • Viewport: the visible browser area is the default and is useful for documenting a screen as a user sees it at a specific viewport size.
  • Full page: use fullPage: true to capture the scrollable page in one image. Lazy-loaded content may need scrolling or explicit loading before capture if it appears only when brought into view.
  • One component: use a locator’s screenshot method when only a particular element is needed.
  • Precise crop: use the screenshot clip option when a rectangle, rather than the entire viewport or a DOM element, defines the desired output.

Example of a component capture:

await page.locator('.product-card').screenshot({ path: 'product-card.png' });

Replace .product-card with a selector that identifies the intended element. If several elements match, make the locator specific enough to select the right one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Control dimensions, format, and image size

Playwright supports PNG, JPEG, and WebP screenshots. PNG is lossless and useful when preserving sharp edges or comparing pixels. JPEG and WebP support a quality value from 0 to 100; that setting does not apply to PNG. WebP at quality 100 is lossless. A screenshot can also be returned as a buffer instead of written directly to a file. Playwright Page API

const image = await page.screenshot({
  type: 'webp',
  quality: 85,
  fullPage: true,
  scale: 'css',
});

Here image is a buffer, suitable for passing to another library or writing elsewhere. Choose scale: 'css' for one output pixel per CSS pixel. scale: 'device' uses device-pixel scale and is the documented default; on high-DPI configurations it can produce larger images. Set the viewport explicitly when dimensions must be consistent across runs.

Make styled screenshots repeatable

A screenshot is only as stable as the page state and rendering environment. Wait for the content that matters, then neutralize irrelevant motion and volatility: animations, rotating promotions, clocks, personalized content, or widgets that change between visits. Capture-time CSS is useful for suppressing such elements without permanently changing the page. Where a specific element must be present, wait for that element or the state it represents rather than relying only on a fixed pause.

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

A fixed delay can still help when a page has no reliable readiness signal, but it may either wait longer than needed or finish before the work is done. Prefer a condition such as a locator becoming visible or an application-specific readiness signal. For dynamic pages, consider disabling animation and transition effects in the screenshot stylesheet, as in the complete example.

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

Use visual regression checks carefully

Playwright Test can create and compare screenshot baselines with toHaveScreenshot(). Playwright visual comparisons documents screenshot assertions and notes that rendering may vary with operating system, browser version, settings, hardware, power source, and headless mode. Run baseline creation and later comparisons in the same environment where possible. Investigate unexplained pixel differences before updating a baseline; a change may reflect a real layout defect, altered content, or a rendering-environment difference.

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

Troubleshoot common capture problems

The CSS has no visible effect

Check that the selector actually matches the page. Inspect the element in browser developer tools or query it with Playwright, for example await page.locator('.cookie-banner').count(). A count of zero means the selector does not identify an element in the current page. Also check whether the target is inside a frame or shadow root; Playwright’s screenshot styling is documented to pierce Shadow DOM and inner frames, but page-side JavaScript selectors may need to target the correct frame or shadow-aware locator.

The screenshot is blank or missing content

Navigation completion does not necessarily mean that a client-rendered application has finished loading its data. Wait for the relevant locator or application state. If an image or section appears only after scrolling, trigger the lazy-load behavior before taking a full-page screenshot. Confirm that the page did not require authentication or another interaction to expose the content.

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.

The capture differs from the previous run

Look first for changing page content, animation, personalization, responsive layout, or a different viewport. Then check that the browser version, host operating system, and headless mode match the baseline environment. Playwright explicitly identifies these environment factors as potential sources of rendering variation. Do not update a baseline until you know whether the difference is expected.

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 output is too large or looks soft

For large files, consider WebP or JPEG with a quality value appropriate to the image, or use CSS-pixel scale instead of device-pixel scale. For crisp pixel-sensitive comparisons, prefer PNG and keep the capture environment and scale fixed. Verify output dimensions against the viewport and whether you requested a full-page image.

Or skip the browser setup

If you want a screenshot endpoint rather than managing a browser, ScreenshotNeo takes a URL and returns an image or PDF. Its screenshot API accepts a URL in one GET request; see the ScreenshotNeo API documentation for parameters and response details.

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

ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots, and every feature is available on every plan. Sign up free for 1,000 screenshots a month with no card.

Which method should you use?

Need Use
Change appearance only for the screenshot Playwright screenshot style
Click, open, remove, or annotate before capture Page interaction or JavaScript before screenshot
Capture a component or crop Locator screenshot or clip
Compare repeat runs Playwright Test screenshot assertions in a consistent environment
Get a screenshot without browser setup ScreenshotNeo API or MCP server

Frequently Asked Questions

Does screenshot CSS change the live website?

No. Playwright’s screenshot style option applies styles for the capture; it does not alter the site for other visitors.

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

Can I capture a single element instead of the whole page?

Yes. Use a locator’s screenshot() method for an element, or the page screenshot clip option for a rectangular crop.

Why can two screenshots of the same page differ?

The page may contain changing content, and rendering can also vary with the operating system, browser version, settings, hardware, power source, or headless mode.

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.