To reduce false visual diffs, first make the page repeatable, then exclude only the known dynamic regions, and finally tune comparison tolerance for small rendering noise that remains. In Playwright, use screenshot-time CSS with stylePath or mask specific elements with mask; avoid loosening the whole image comparison to hide a local problem.
Choose the right kind of filtering
A visual diff can be addressed at two different stages: change what appears in the screenshot, or change how the comparison evaluates pixels. Filtering a known variable region is usually more precise than relaxing comparison for the entire page: a broad tolerance can allow unrelated changes through.
- Stabilize page state: make content, viewport, browser, fonts, and interaction state consistent between runs.
- Exclude a known volatile region: mask it or hide/change it using CSS at screenshot time.
- Tolerate residual rendering noise: adjust color threshold or an allowed differing-pixel count only when capture is already stable.
Filter screenshots in Playwright
Playwright Test compares screenshots against stored baselines with expect(page).toHaveScreenshot(). The assertion supports masks and a stylesheet applied for capture. See the PageAssertions API and Visual comparisons guide for current option details.
Mask a volatile element
Use a locator for a region whose exact content varies but whose space should remain in the image. For example, this test masks a changing timestamp:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import { test, expect } from '@playwright/test';
test('account page visual baseline', async ({ page }) => {
await page.goto('https://example.com/account');
await expect(page).toHaveScreenshot('account.png', {
mask: [page.locator('[data-testid="last-updated"]')],
});
});
Replace the URL and selector with your page and a stable selector. Keep masks narrowly scoped: if a locator matches a large area or multiple unintended elements, meaningful visual changes inside it will not be compared.
Hide changing content with capture-time CSS
Use stylePath when the region should disappear or be altered only in the screenshot. Create a stylesheet such as tests/visual.css:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
[data-testid="live-ad"],
[data-testid="rotating-promo"] {
visibility: hidden !important;
}
Then apply it to the screenshot assertion:
import { test, expect } from '@playwright/test';
test('landing page visual baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('landing.png', {
stylePath: 'tests/visual.css',
});
});
The stylesheet is applied during capture and can hide elements or change their properties. Prefer selectors that identify only intentionally variable content; do not hide a whole component merely because one value inside it changes.
Control capture state before comparing
- Use the same viewport, browser and test environment for baseline creation and comparison. Differences in fonts or operating systems can produce image changes; Playwright does not prescribe one universally correct tolerance for every environment.
- Ensure the page has reached the relevant state before taking the screenshot, rather than capturing during an animation or partial load.
- Playwright captures the hover state present at the time of capture. If pointer hover styling is accidental noise, move the mouse to a neutral point or an element without hover styling before the assertion.
- Keep the selector, page state and screenshot scope stable. A selector that stops matching can leave the variable content unfiltered.
Set comparison tolerances only for residual noise
After stabilizing the capture and filtering known dynamic areas, use comparison settings for small remaining rendering differences. Playwright documents threshold as a perceived color-difference value from 0 (strict) to 1 (lax), with a default of 0.2. maxDiffPixels permits a chosen number of differing pixels and is unset by default. These settings can be configured for an assertion or at test/project level; see the API reference.
Recommended Free Tools
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
For example, a deliberately small pixel allowance can be set on one assertion:
await expect(page).toHaveScreenshot('account.png', {
maxDiffPixels: 40,
});
This is an example value, not a universal recommendation. Choose tolerance against your own stable browser and environment, inspect the resulting diffs, and keep the scope as narrow as the problem permits. Increasing a global threshold is not equivalent to excluding one timestamp: it can make unrelated changes less likely to fail as well.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Review diffs before updating a baseline
When a screenshot changes, inspect the diff and determine whether the change is expected. Updating a baseline records the new output; it does not establish that the UI change is intentional.
- Run the visual test and open the actual-versus-expected diff.
- Check whether the difference is an intended design/content change, unstable page state, a known volatile region, or rendering noise.
- Fix the source of instability or add a narrowly scoped mask/style before changing broad tolerances.
- Only after approving an intentional change, refresh snapshots with
npx playwright test --update-snapshots.
When Percy fits better
Percy’s Playwright integration is a hosted visual-testing alternative when a team wants service-based diff review and region-level controls. Its documentation describes ignored regions selected with CSS selectors, XPath, or custom coordinates, plus custom CSS before capture, animation options, and per-region algorithms/configuration. See the Percy Playwright client library documentation for current behavior and availability. Choose between local Playwright baselines and a hosted workflow based on how your team wants to inspect and approve visual changes; no universal approval policy is implied by either tool’s baseline mechanics.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. A single request can return an image or PDF; this example saves a WebP screenshot:
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://example.com
-o shot.webp
See the ScreenshotNeo API documentation for authentication and options. It accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and responses include page-verdict and billed headers. Its MCP server gives AI agents screenshot tools. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free 1,000 screenshots a month, with no card required.
Frequently Asked Questions
Does Playwright mask remove an element from the page?
No. A screenshot mask affects the comparison image for the specified locator; use capture-time CSS when the goal is to hide or alter page content in the captured image.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Can I set a different tolerance for one region in Playwright?
The documented Playwright screenshot assertion exposes comparison settings such as threshold and maxDiffPixels for the screenshot comparison; use masks or capture CSS to isolate a particular region. Percy documents region-specific comparison configuration.
Should I update a snapshot whenever a test fails?
No. Review the difference and decide whether it reflects an intended visual change before refreshing the baseline.
Quick Recap
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.

