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

In Playwright Test, use toHaveScreenshot() with its mask option to ignore timestamp and ad pixels while preserving the page layout. If you want those elements absent instead, hide them with screenshot-time CSS—but choose the CSS rule carefully, because hiding can affect layout.

Mask timestamps and ads in Playwright

Mask the smallest elements that contain changing content. The page remains in place, but the matched areas are covered in the screenshot so their changing pixels do not drive a content diff.

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

test('page visual check', async ({ page }) => {
  await page.goto('/');
  await expect(page.getByRole('main')).toBeVisible();

  await expect(page).toHaveScreenshot({
    mask: [
      page.getByTestId('timestamp'),
      page.locator('[data-testid="ad-slot"]'),
    ],
  });
});

Use selectors that are specific and stable, such as test IDs your application owns. If the ad is rendered inside a distinct slot, mask that slot rather than a large surrounding region. A broad mask can conceal a real layout or styling regression near the dynamic content.

Hide volatile content with screenshot-time CSS

Use the screenshot API’s style option when you want to remove visible timestamp or ad content from the capture instead of covering it with a mask:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
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({
  style: `
    [data-testid="timestamp"],
    [data-testid="ad-slot"] {
      visibility: hidden !important;
    }
  `,
});

The screenshot stylesheet can hide dynamic elements or otherwise change their properties for a more repeatable capture. Playwright documents that this style reaches Shadow DOM and inner frames. See the Playwright screenshot API.

  • visibility: hidden hides the content while preserving the space it occupies.
  • display: none removes the element from layout, which can shift neighboring content and create differences beyond the target area.

Hiding is appropriate only when the altered capture layout is acceptable for the question your test is meant to answer. Keep assertions for layout and behavior separate where needed.

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

Choose masking or hiding based on what the test must catch

Approach What changes in the capture Best fit
Locator mask The selected screenshot area is covered; page layout stays present. Volatile pixels should not matter, but surrounding layout should remain visible.
Screenshot-time CSS The selected content is hidden or otherwise styled for capture; layout effects depend on the CSS rule. You do not want an overlay, and the capture-time styling is acceptable.
Pixel-difference tolerance Small rendering differences are tolerated according to the configured threshold. Known, minor rendering noise—not a substitute for targeting dynamic regions.

For hosted workflows, Chromatic supports .chromatic-ignore, data-chromatic="ignore", and CSS selector lists. Its documentation says ignored pixels are disregarded, but dimension changes to an ignored element can still trigger a diff. See Chromatic’s ignore-elements documentation and Chromatic for Playwright. Percy’s Playwright documentation describes ignore regions selected by CSS, XPath, or coordinates, and screenshot-time Percy CSS; check behavior against the version your project uses: Percy Playwright README.

Keep visual regression checks diagnostic

  1. Target only the changing region. Prefer stable, component-specific selectors so a mask cannot hide unrelated regressions.
  2. Control the state you can. Wait for the page state relevant to the test and control time or data in the test where practical. Masking reduces visual noise; it does not verify application data or ad behavior.
  3. Keep baseline environments consistent. Playwright notes that rendering can vary with host OS, browser version, settings, hardware, power source, headless mode, and other factors. Generate and compare baselines in the same environment where practical; use separate baselines for materially different browser/platform combinations. See Playwright visual comparisons.
  4. Review baseline updates. Playwright creates a reference screenshot on the first run and, while generating baselines, captures repeatedly until two consecutive screenshots match, then saves the last one. Commit and review reference files. To intentionally update them, run npx playwright test --update-snapshots.

Troubleshoot noisy or misleading diffs

  • The timestamp still causes a diff: confirm the locator matches the rendered timestamp at capture time. Prefer a stable test ID; check whether the timestamp is inside a different component or frame.
  • The ad mask hides too much: narrow the selector to the ad slot instead of masking a parent or page-wide region.
  • Nearby content shifts after hiding: replace display: none with visibility: hidden if preserving occupied space is the intended behavior, or use a mask.
  • Unexpected diffs remain across runs: verify the page is in the expected state before capture, then compare browser, operating system, headless mode, and other baseline environment settings.
  • A snapshot update changes many areas: inspect the new images before accepting them. A baseline update should be intentional, not an automatic response to every failure.

Or skip the browser setup

For one-off captures or automation outside a Playwright test suite, ScreenshotNeo provides a screenshot API. This example captures a page directly; it does not configure a visual-regression baseline or masking selectors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
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.
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 request options. ScreenshotNeo accepts cookie and consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers indicating the page verdict and billing status. Its MCP server offers screenshot and page-information tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. These are general page-capture features, not a replacement for Playwright’s locator-level masking in a test baseline.

Sign up free for 1,000 screenshots a month with no card.

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

Frequently Asked Questions

Does masking remove the timestamp or ad from the page?

No. It covers the matched area in the screenshot; it does not change the page itself.

Rank #4
Sale
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

Should I mask an entire ad container or just the changing creative?

Mask the smallest region that is genuinely volatile. Masking a whole slot is reasonable when the entire slot changes, but avoid covering nearby content whose regressions matter.

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.

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.