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 DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk7 min

How to Use Playwright to Compare Website Screenshots in CI

Use Playwright Test’s toHaveScreenshot() to compare pages with reviewed baselines in CI. Learn how to keep captures stable, diagnose diffs, and update snapshots safely.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright Test’s expect(page).toHaveScreenshot() assertion to compare a rendered page with a reviewed, version-controlled baseline. For reliable CI results, generate and compare baselines with a consistent operating system, Playwright and browser versions, and screenshot settings; investigate environment and content changes before treating a diff as an application regression.

What Playwright’s screenshot comparison does

toHaveScreenshot() is Playwright Test’s purpose-built visual comparison assertion. It captures the page and waits until two consecutive screenshots are identical before comparing the result with the expected image. The first run, when no reference exists, creates a baseline; later runs compare against it. See the Playwright Visual comparisons guide and the PageAssertions API.

As an Amazon Associate I earn from qualifying purchases.

These are screenshot assertions provided by the Playwright Test runner, not a general assertion available in every Playwright library context. For screenshots, prefer toHaveScreenshot() over passing a screenshot buffer to toMatchSnapshot(); the SnapshotAssertions API cautions against that approach.

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.

Write a test for a stable page state

Navigate to the page, assert that the content or state you intend to capture is ready, and then take the screenshot. A navigation completing does not by itself establish that the important UI is visible, so include an assertion for a meaningful page element.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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
import { test, expect } from '@playwright/test';

test('home page visual baseline', async ({ page }) => {
  await page.goto('/');
  await expect(page.getByRole('heading', { name: 'Welcome' })).toBeVisible();
  await expect(page).toHaveScreenshot('home.png');
});

This is an illustrative example based on Playwright’s documented API. Replace the route and heading with your application’s URL and a reliable readiness condition. The example assumes your Playwright project is already configured with a base URL if you use the relative route /.

Create, review, and commit the baseline

  1. Run the test once in the environment you intend to use for baseline generation. With no expected image present, Playwright writes a reference screenshot.

  2. Open the generated image and check that it shows the intended page state, viewport, and content—not a loading screen, consent dialog, or accidental error state.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Commit the generated snapshot directory to version control. The test file name contributes to the generated snapshot folder. If your repository needs another layout, configure the snapshot path template in Playwright Test.

  4. Run the test again. It now compares the capture with the committed reference and reports a mismatch if the comparison exceeds the configured tolerance.

    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

Keep reference images under review like source changes. When a UI change is intentional, update the baseline deliberately with --update-snapshots, inspect the new image and diff, and commit the accepted result. Do not make ordinary CI failures automatically rewrite expected screenshots: doing so can erase the signal that visual regression tests are meant to provide. See the visual comparison guide.

Make local and CI captures reproducible

Playwright documents that screenshot output can vary with the host operating system, browser version, settings, hardware, power source, and headless mode. Its guidance is direct: “For consistent screenshots, run tests in the same environment where the baseline screenshots were generated.” Match the material parts of the environment between baseline creation and CI, rather than assuming an image created on a developer’s machine will be pixel-identical on a different runner.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Pin Playwright: keep the version in your project dependency lockfile and use that locked version in CI.
  • Install its matching browser binaries: browser builds correspond to Playwright versions. After updating Playwright, install the browser binaries for that version. The browser guide documents npx playwright install and npx playwright install --with-deps chromium.
  • Keep the host consistent: use the same operating system and materially relevant screenshot settings for baseline generation and CI. Check fonts, viewport, scale, browser build, and test state when diagnosing a diff.
  • Install system dependencies: ensure the CI image has the dependencies required by the selected browser. Linux headed tests also need Xvfb; Playwright’s default browser execution is headless. See the Continuous Integration guide.
  • Separate intentional environments: if you test multiple browsers or platforms, use separate Playwright projects and corresponding expectation sets where their output is expected to differ. Playwright WebKit is derived from WebKit main-branch sources and is not branded Safari; for the closest Safari experience, the browser guide recommends running WebKit on macOS. Platform-sensitive behavior, including codecs, can differ.

Playwright generally does not recommend caching browser binaries in CI: restoring the cache can take as long as downloading the browsers, and Linux system dependencies cannot be cached. If you choose to cache browser binaries anyway, key the cache to the Playwright version. The CI guide explains the trade-off.

Control volatility without hiding real changes

Let the assertion settle, then stabilize the page itself

Page screenshot assertions already wait for two consecutive identical captures. They also disable animations by default. These controls help with transient rendering, but they cannot make genuinely changing application content identical. If a timestamp, rotating promotion, or other region is intentionally volatile, consider a narrowly scoped stylesheet through stylePath. Playwright documents that this can affect content in frames and Shadow DOM as well.

Document why each excluded region is unstable and keep the exclusion narrow. Hiding a region that users rely on may make the test pass while concealing a visual defect. See the PageAssertions API.

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.

Set a difference budget only from reviewed evidence

The threshold option sets the acceptable perceived per-pixel color difference in YIQ space; its documented default is 0.2. maxDiffPixels and maxDiffPixelRatio limit the count or ratio of changed pixels and are unset unless configured. These settings can be configured globally or per project; their behavior and configuration are described in the PageAssertions API and TestConfig API.

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

Start with strict comparisons. If you change a tolerance or add a pixel budget, base it on reviewed diffs and treat it as a team policy, not a universal Playwright recommendation. For example, this configuration uses an illustrative budget of ten changed pixels; Playwright does not recommend that particular value:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  expect: {
    toHaveScreenshot: {
      maxDiffPixels: 10,
      // Add stylePath only when it removes documented volatile content.
    },
  },
});

A generous tolerance can suppress noise, but it can also let a real user-visible change pass. Don’t use a broad budget as a substitute for stabilizing the test state.

Choose snapshot formats and project layouts

Screenshot assertion baselines default to PNG. The assertion can also use a .webp extension for lossless WebP. Choose a format and naming convention that suit your repository, and keep them consistent for the relevant project. If separate browser or platform projects produce meaningfully different images, give each an appropriate expectation set instead of comparing unlike environments against one baseline. The format and project options are documented in the visual comparisons guide and PageAssertions API.

Diagnose a failing screenshot comparison

A mismatch can indicate an application change, but environmental or content variability can produce one too. Compare the actual image and diff before accepting a baseline update.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • 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
  1. Confirm the test reached the intended state. Check the page’s visible content and readiness assertion. A capture taken before the right state is ready is not a useful baseline comparison.

  2. Compare environments. Check operating system, Playwright and browser versions, browser mode, fonts, viewport, scale, and material settings against the baseline-generation environment.

  3. Look for dynamic content. Identify rotating, time-dependent, or externally changing content. If a specific region is legitimately volatile, use a documented, narrow stylePath exclusion rather than hiding broad areas.

  4. Inspect the diff and tolerance. Decide whether the change is meaningful before changing threshold, maxDiffPixels, or maxDiffPixelRatio. Do not loosen comparison settings merely to silence an unexplained failure.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  5. Update only for an accepted UI change. Run with --update-snapshots, review the generated images and diff, and commit the intentional baseline change.

    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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to capture a website rather than maintain a Playwright visual-regression suite, ScreenshotNeo is a website screenshot API and MCP server for developers. Its API can return a screenshot or PDF from one GET request. For example, save a WebP capture of Stripe with cURL:

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 API documentation for the request options. ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots, and responses include X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

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.

Frequently Asked Questions

Can I compare a screenshot buffer with Playwright snapshot assertions instead?

For screenshot comparisons, Playwright’s API documentation recommends the purpose-built toHaveScreenshot() assertion rather than toMatchSnapshot() on a screenshot buffer.

Does Playwright WebKit produce the same screenshots as Safari?

No. Playwright WebKit is derived from WebKit main-branch sources and is not branded Safari; platform-sensitive behavior can differ.

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.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.