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

In Playwright, a screenshot is an image of rendered pixels; a snapshot is saved expected data used for comparison. Playwright uses “snapshot” for several artifacts, so the correct assertion depends on what you want to verify: use toHaveScreenshot() for visual pixels, toMatchSnapshot() for text or arbitrary serialized data, and toMatchAriaSnapshot() for the accessibility-tree structure. A visual screenshot can also be called a screenshot snapshot when it is stored as a baseline, which is why the terms sometimes overlap.

Screenshot vs. snapshot at a glance

Question Screenshot assertion Generic or ARIA snapshot
What is captured? Rendered pixels in an image file. A value such as text or binary data, or an accessibility-tree representation.
Playwright API expect(page).toHaveScreenshot() expect(value).toMatchSnapshot() or toMatchAriaSnapshot()
What changes fail the check? Visual differences beyond the comparison tolerance. Differences in the stored value, serialized output, roles, names, or hierarchy.
Typical use Visual regression: layout, colors, typography, spacing, and images. Stable content contracts or accessibility regressions.
Reference artifact A baseline image generated on the first run and compared later. A text, binary, or accessibility snapshot kept with the test.

The words are not mutually exclusive. A baseline PNG produced by toHaveScreenshot() is often described as a “screenshot snapshot,” but it is still an image comparison, not a generic value snapshot.

What Playwright means by a screenshot

A screenshot is a raster image captured from a page or locator. The image records what the browser rendered at that moment: positions, dimensions, fonts, colors, borders, shadows, and visible content. It is the right artifact when the question is, “Does this interface still look the way it should?”

Playwright Test’s visual assertion is:

await expect(page).toHaveScreenshot();

With a name, you can control the baseline filename and keep several views for one test:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#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
await expect(page).toHaveScreenshot('home.png', { fullPage: true });

The assertion captures screenshots until two consecutive captures match, then compares the final image with the expected reference. This repeat-capture behavior helps avoid comparing a frame that is still changing. On the first run, when no baseline exists, Playwright Test writes one. Later runs compare the newly captured image against that stored baseline.

toHaveScreenshot() is a Playwright Test assertion, so run it through the Playwright test runner rather than a standalone browser script. A complete JavaScript test looks like this:

import { test, expect } from '@playwright/test';

test('home page visual baseline', async ({ page }) => {
  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await expect(page).toHaveScreenshot('home.png', { fullPage: true });
});

Install the test package and browsers in a new project, then run the test normally. The first successful run creates the expected image; subsequent runs report a visual diff when the rendered result no longer matches.

What Playwright means by a snapshot

A generic snapshot stores an expected value. That value might be a string, JSON serialization, or arbitrary binary data. Playwright compares the value produced by the current test with the stored snapshot and reports a mismatch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { test, expect } from '@playwright/test';

test('heading text contract', async ({ page }) => {
  await page.goto('https://example.com');
  const heading = await page.locator('h1').textContent();
  expect(heading).toMatchSnapshot('home-heading.txt');
});

This test checks text, not pixels. A font change, a one-pixel shift, or a different image does not matter if the heading string is unchanged. Conversely, a changed word fails even when the page looks identical.

toMatchSnapshot(name) can also compare serialized or binary values. It is therefore useful for generated documents, API responses, or other deterministic output. Playwright’s snapshot assertion guidance points to toHaveScreenshot() when the artifact you actually want to compare is a page image; using a generic value snapshot for a screenshot obscures that intent.

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

ARIA snapshots are a third kind of snapshot

toMatchAriaSnapshot() compares an accessibility-tree representation rather than pixels or raw text. The representation contains roles, accessible names, hierarchy, and related accessibility information exposed to assistive technology.

import { test, expect } from '@playwright/test';

test('main content remains accessible', async ({ page }) => {
  await page.goto('https://example.com');
  await expect(page.locator('main')).toMatchAriaSnapshot(`
- heading "Example Domain"
- paragraph
`);
});

An ARIA snapshot can pass while a page’s colors or spacing change, because those are visual properties. It can fail when a heading loses its role, a button’s accessible name changes, or the hierarchy is altered, even if the screenshot looks nearly the same. Use it when the contract is semantic structure, not appearance.

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.

Which assertion should you choose?

Choose toHaveScreenshot() for appearance

  • Responsive layout, spacing, alignment, and component geometry.
  • Typography, colors, borders, shadows, and visible images.
  • Visual regression checks for a page or a particular locator.

Choose toMatchSnapshot() for a value

  • Text whose exact wording must remain stable.
  • Serialized JSON or other deterministic output.
  • Binary data that is not being judged as rendered pixels.

Choose toMatchAriaSnapshot() for accessibility structure

  • Roles and accessible names.
  • Heading, landmark, list, and control hierarchy.
  • Semantic regressions that a pixel diff cannot reliably identify.

Many teams use all three in one suite: an image baseline for high-value visual surfaces, focused value snapshots for generated content, and ARIA snapshots for critical interaction areas. They answer different questions and should not be substituted for one another.

How visual baselines are created and maintained

  1. Write the visual assertion. Navigate to a deterministic page state and call toHaveScreenshot() on the page or a locator.
  2. Generate the initial baseline. Run the test in the environment you intend to standardize. The first run writes the expected image when no reference exists.
  3. Run the test again. Playwright captures until two consecutive images match, then compares that result with the baseline.
  4. Inspect intentional changes. If a redesign is correct, review the produced diff and update the baseline deliberately rather than accepting every change automatically.
  5. Keep the environment consistent. Commit the baseline files with the test and run comparisons in the same browser and operating environment whenever possible.

Updating a baseline is a code-review decision. A changed image can represent a legitimate design change, a browser upgrade, a missing font, a timing issue, or an application bug. Treat the image diff as evidence to investigate, not as an instruction to overwrite the reference.

Why the same screenshot can differ between machines

Playwright’s visual-comparison documentation warns that browser rendering can vary with the host operating system, browser version, settings, hardware, power source (battery versus power adapter), headless mode, and other factors. Fonts, GPU behavior, device scale, animation timing, and network-delivered content can all affect pixels.

For reliable comparisons:

  • Generate and compare baselines in the same container or CI image when practical.
  • Pin the browser version used by the test project.
  • Use stable test data and wait for the page state your assertion requires.
  • Disable or control content that changes between runs, such as rotating promotions or live timestamps.
  • Review diffs after operating-system, browser, font, or hardware changes before mass-updating references.

These controls matter for screenshot assertions far more than for a text snapshot. A text value is usually insensitive to font rasterization and subpixel positioning; an image is not.

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.

A practical Playwright workflow

Set up a visual test

npm init playwright@latest
npx playwright test

Choose the JavaScript or TypeScript project option during setup, then add a test such as:

import { test, expect } from '@playwright/test';

test('checkout summary', async ({ page }) => {
  await page.goto('https://example.com/checkout');
  await expect(page.locator('[data-testid="summary"]'))
    .toHaveScreenshot('checkout-summary.png');
});

Scoping the assertion to a locator keeps unrelated page changes out of the baseline. Use a page-level assertion when the entire page is the product you want to protect.

Generate or intentionally update references

Run the test once to create a missing baseline. When a reviewed design change is intentional, run the suite with Playwright’s snapshot-update mode:

npx playwright test --update-snapshots

Review the resulting image files in version control. Do not use update mode as a blanket fix for unexplained failures.

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

Combine visual and semantic checks

test('account card', async ({ page }) => {
  await page.goto('https://example.com/account');
  await expect(page.locator('[data-testid="account-card"]'))
    .toHaveScreenshot('account-card.png');
  await expect(page.locator('[data-testid="account-card"]'))
    .toMatchAriaSnapshot(`
- heading "Account"
- button "Edit profile"
`);
});

The image protects appearance while the ARIA snapshot protects the accessible contract. Add a generic toMatchSnapshot() only when a separate text or serialized value is itself important.

Troubleshooting screenshot and snapshot failures

“No baseline found” on the first run

Cause: The test has not generated its expected artifact yet.

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

Fix: Run the test once in the approved environment, inspect the generated image or value, and commit it if it is correct.

Visual diffs appear only in CI

Cause: CI and local machines differ in OS, browser build, fonts, hardware, power state, or headless configuration.

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

Fix: Standardize the execution image and browser version, then regenerate baselines there. Do not mix references produced on materially different systems.

The screenshot changes on every run

Cause: The page is still changing when it is captured: animations, delayed content, rotating data, or unstable network responses are common causes.

Fix: Navigate to a deterministic state, wait for the required content, control test data, and remove or freeze sources of randomness before comparing pixels.

A text snapshot fails after an intentional copy edit

Cause: toMatchSnapshot() compares the exact stored value.

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

Fix: Confirm the new text is correct, review the diff, and update only that snapshot. If wording should be flexible, assert the specific rule you need instead of storing the entire string.

An ARIA snapshot fails but the page looks unchanged

Cause: Accessibility roles, names, or hierarchy changed without a major visual change.

Fix: Inspect the accessibility tree and correct the semantic markup or the expected template. Do not replace an ARIA assertion with a screenshot merely to make the test pass.

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 simply to obtain a clean image or PDF from a URL rather than maintain Playwright baselines, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF output. It accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and whether the request was billed.

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

Use the ScreenshotNeo documentation for the complete parameter list. A minimal cURL request is:

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

The equivalent 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)

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}`);

ScreenshotNeo also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper sizes and page ranges, custom CSS and JavaScript, pre-capture clicks, selector hiding, waits for selectors, delays or network idle, ad/tracker/request blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

Plan Included shots 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 available on every plan. Create a free ScreenshotNeo account to use 1,000 screenshots each month without adding a card.

FAQ

Frequently Asked Questions

Can I use toMatchSnapshot() to compare a screenshot file?

You can compare binary data with a generic snapshot, but toHaveScreenshot() expresses a rendered-image comparison directly and is the preferred Playwright assertion for page screenshots.

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

Does a screenshot baseline test prove accessibility?

No. A pixel image can look correct while roles, names, or hierarchy are wrong. Add toMatchAriaSnapshot() or targeted accessibility assertions for semantic coverage.

Should visual baselines be regenerated after every browser upgrade?

Not automatically. Run the suite in the upgraded environment, inspect the diffs, and update references only after deciding that the rendering changes are intentional.

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.