Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

How to Ignore Timestamps and Ads in Visual Regression Screenshots

Mask specific timestamp and ad locators in Playwright, or hide them with screenshot-time CSS when its layout effects are acceptable.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Playwright Test, ignore changing timestamps and ads by masking their specific locators in toHaveScreenshot(). The page layout stays in place while the selected screenshot pixels are covered. If you would rather remove the elements from the capture, use screenshot-time CSS—but choose a rule that will not shift surrounding content unless that shift is acceptable.

Mask timestamps and ads with Playwright

Playwright Test’s toHaveScreenshot() supports a mask option that covers the screenshot area matched by each locator. Keep the locators narrow: masking a whole page region can conceal the layout regressions the test is meant to catch.

As an Amazon Associate I earn from qualifying purchases.

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 stable selectors that your application controls, such as test IDs. If an ad changes within a defined slot, mask that slot rather than a broad parent containing other content. Playwright documents the screenshot assertion and its options in its visual comparisons guide and PageAssertions API.

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

What masking does—and does not do

Masking covers selected pixels in the screenshot; it does not remove the underlying element or establish that its data or behavior is correct. Keep separate functional checks if the timestamp or ad behavior matters. A mask is for reducing irrelevant visual noise, not for making a failing application pass unnoticed.

#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

Hide volatile elements with screenshot-time CSS

Use the screenshot API’s style option when you want the selected content hidden rather than covered by a mask. The stylesheet is applied for the capture, including in Shadow DOM and inner frames, according to the Playwright screenshot API.

await expect(page).toHaveScreenshot({
  style: `
    [data-testid="timestamp"],
    [data-testid="ad-slot"] {
      visibility: hidden !important;
    }
  `,
});

visibility: hidden preserves the space occupied by the element. By contrast, display: none removes it from layout and may move nearby content, creating changes beyond the target. Test the chosen CSS against the page and its layout assertions before relying on it.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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 an ignore method that preserves useful diffs

Approach Effect on capture Useful when Watch for
Playwright locator mask Covers the matched screenshot area while leaving page structure in place. You want noisy pixels ignored but the surrounding layout retained. A broad locator can hide meaningful visual changes inside its area.
Screenshot-time CSS Changes the captured element’s visibility or other properties. You do not want the element visible in the image. display: none can alter layout; prefer visibility: hidden when preserving space matters.
Chromatic ignore Ignored pixels are disregarded; changes to an ignored element’s dimensions can still trigger a diff. You use Chromatic’s hosted review workflow and want dimension changes to remain detectable. Check the current product documentation and project integration.
Percy ignore Percy’s Playwright documentation describes CSS selectors, XPath, rectangular coordinates, and screenshot-time CSS. Your team already uses Percy and its review workflow. Check behavior against the version in your project.

Chromatic documents its options in Ignore elements and its Playwright workflow in Chromatic for Playwright. Percy’s documented Playwright integration is in its Percy Playwright README. These hosted products are optional; native Playwright masking or screenshot styling can handle the core use case.

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

Make baselines stable and reviewable

  1. Wait for the state you intend to test. Navigate and assert that the relevant page content is visible before capturing. Stabilize time or test data where practical; masking does not control the application’s data.
  2. Keep the capture environment consistent. Playwright warns that browser rendering can vary with host OS, browser version, settings, hardware, power source, headless mode, and other factors. Use the same environment for baseline generation and comparison where practical, and maintain separate baselines for materially different browser or platform combinations. See Playwright visual comparisons.
  3. Review reference changes intentionally. Playwright creates a reference screenshot on the first run and, while generating a baseline, captures repeatedly until two consecutive screenshots match, then saves the last one. Commit and review reference files. Update intentionally with npx playwright test --update-snapshots; inspect the resulting images rather than accepting every change automatically.
  4. Use tolerance only for small known noise. Pixel-difference tolerances can accommodate limited rendering variation, but are not a substitute for targeting dynamic content precisely.

Troubleshooting visual diffs

The timestamp or ad still changes the test result

  • Confirm the locator matches the element in the rendered page and that it is included in the mask array.
  • Prefer an application-owned test ID or a selector scoped to the specific timestamp or ad slot.
  • If the content lives in a frame, target it appropriately and verify the screenshot-time style is applied to that frame; Playwright’s stylesheet option reaches inner frames.

Content next to an ignored element shifts

Check whether the CSS uses display: none or another layout-changing property. Use a mask to preserve the page structure, or use visibility: hidden when hiding the element while retaining its space.

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.

Unrelated screenshot regions differ between runs

Wait for the relevant page state, stabilize data and time where possible, and compare screenshots in a consistent browser and host environment. Do not expand the mask to cover unrelated changes; doing so can hide genuine regressions.

Or skip the browser setup

For a one-off screenshot rather than a Playwright baseline comparison, ScreenshotNeo can return a screenshot through one GET request. For example, this cURL command saves a WebP screenshot of Stripe; substitute your target URL and API key:

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
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 request options. ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers identifying 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 with no card; paid plans start at $5 for 3,000 shots.

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

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

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

Frequently Asked Questions

Does masking an element test whether it rendered correctly?

No. Masking suppresses its screenshot pixels; it does not verify the element’s content or behavior.

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.

Can I use screenshot-time CSS inside frames?

Playwright documents that the screenshot stylesheet reaches Shadow DOM and inner frames. Verify that your selector matches the intended element in the captured page.

Should I increase pixel tolerance instead of masking an ad?

Not when the variation is localized and identifiable. A targeted mask avoids relaxing comparisons across unrelated pixels.

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

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
Crashes, No Sound, or Screen Glitches?Free driver scan
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.