Recommended Free Tools
Use the mask option and give Playwright one or more locators for the regions that should be hidden in a visual screenshot. Playwright paints each matched element’s bounding box with a pink overlay by default; set maskColor to change it. The option works with page and locator screenshots as well as toHaveScreenshot() assertions.
What Playwright masking does
A screenshot mask is a visual overlay applied while Playwright captures the image. The page is not changed, and the dynamic value is not made deterministic. Instead, the matched element’s bounding box is covered in the image that is compared with, or saved as, the screenshot.
The default overlay color is #FF00FF (pink). You can provide another CSS color through maskColor. Because the overlay covers the complete bounding box, a selector that is wider than the volatile content can hide nearby pixels as well.
Masking is intended for rendered-image assertions. Use toHaveScreenshot() for Playwright Test visual comparisons, rather than a generic snapshot assertion.
#1 Best Overall
- 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
Basic syntax with a visual assertion
Install and configure the Playwright Test runner, then pass a locator array in the assertion options:
import { test, expect } from '@playwright/test';
test('account page hides the changing balance', async ({ page }) => {
await page.goto('https://example.com/account');
await expect(page).toHaveScreenshot('account.png', {
mask: [page.getByTestId('dynamic-account-value')],
});
});
The named screenshot form stores or compares account.png. You can also omit the name when using the page-wide assertion:
await expect(page).toHaveScreenshot({
mask: [page.getByTestId('dynamic-account-value')],
});
Playwright’s screenshot assertion waits for two consecutive screenshots to be identical before it compares them. Masking therefore removes a known volatile region, while the stabilization wait handles changes that are still settling elsewhere on the page.
Masking a component instead of the whole page
Use a locator assertion when the test is concerned with one component:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesconst card = page.getByTestId('profile-card');
await expect(card).toHaveScreenshot('profile-card.png', {
mask: [card.getByTestId('last-seen')],
});
The screenshot is scoped to profile-card, and the mask is evaluated inside that capture. This keeps unrelated page changes out of a component-level visual test.
For a standalone capture rather than an assertion, the page and locator screenshot APIs accept the same option:
await page.screenshot({
path: 'dashboard.png',
fullPage: true,
mask: [page.getByTestId('live-stock-price')],
maskColor: '#444444',
});
await page.getByTestId('invoice').screenshot({
path: 'invoice.png',
mask: [page.getByTestId('generated-invoice-number')],
});
Use locator-based APIs instead of ElementHandle.screenshot(); locator methods are the preferred way to identify and capture elements.
Rank #2
- 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
Choosing a locator that masks only what you intend
Locators determine both what is covered and how robust the test is. Prefer a stable, narrowly scoped locator for the changing region.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Test IDs for explicit visual-test hooks
mask: [page.getByTestId('random-avatar')]
A test ID is useful when the product team can mark a region specifically for automation.
Roles, labels, text and other built-in locators
Use role locators for interactive controls and text locators for visible text content when those descriptions are stable:
mask: [page.getByRole('status', { name: 'Current time' })]
Labels, placeholders, alternative text and titles are also available when they uniquely identify the target. Avoid selectors based on generated class names or DOM positions; they tend to break when styling or layout changes.
CSS selectors for a precise region
mask: [page.locator('[data-volatile="price"] .amount')]
Keep the selector as close as possible to the changing pixels. If the volatile number is inside a large panel, masking the entire panel will hide stable content that the screenshot should continue to protect.
Hidden matches are masked too
Playwright applies a mask to matching elements even when a match is invisible. A broad selector can therefore mask a hidden template, duplicate menu, or off-canvas element that you did not expect to affect the screenshot.
If only visible elements should be covered, constrain the locator with a visibility filter:
Rank #3
- 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.
const visibleNotice = page
.locator('[data-testid="notice"]')
.filter({ visible: true });
await expect(page).toHaveScreenshot({
mask: [visibleNotice],
});
Inspect the DOM and locator matches when a mask appears to have no effect or covers an unexpected area. A visibility constraint expresses the intent explicitly instead of relying on the element’s current state.
Page-wide versus element-level screenshots
| Capture scope | Use it when | Main masking consideration |
|---|---|---|
expect(page).toHaveScreenshot() |
You are guarding the complete rendered page or a full-page visual regression. | A broad mask can hide unrelated content; use a tight locator and enable full-page capture only when the test needs it. |
expect(locator).toHaveScreenshot() |
You are protecting one component, card or region. | Keep the mask inside the component and ensure it identifies the intended descendant. |
page.screenshot() or locator.screenshot() |
You need a saved image without a visual assertion. | The same bounding-box overlay rules apply, including the treatment of invisible matches. |
Choose the smallest capture scope that matches the test’s purpose. A page assertion checks integration and layout across the page; a locator assertion gives a more focused component contract.
Multiple masks and a custom color
Pass every changing region in one array. All matching boxes receive the same overlay color for that capture:
await expect(page).toHaveScreenshot('checkout.png', {
mask: [
page.getByTestId('session-id'),
page.getByTestId('recommendation-carousel'),
page.getByRole('status', { name: 'Payment processing time' }),
],
maskColor: '#222222',
});
Use a color that is easy to recognize in review. Changing the color changes the expected image, so keep it consistent across a project unless a particular test needs a different convention.
What masking does not solve
- Layout instability: If a changing value changes its width, the surrounding layout can still move. Mask the smallest stable container that includes the layout effect, or make the test data deterministic.
- Animations and transitions: A mask does not stop animation elsewhere on the page. Disable or wait for animations as part of page setup.
- Network and loading races: Wait for the page state your test requires before taking the screenshot. The assertion’s consecutive-capture stabilization is not a replacement for reliable setup.
- Incorrect selector scope: A mask hides a locator’s bounding box, not an arbitrary substring inside it. Refine the locator when the overlay is too large.
Do not confuse visual snapshots with other snapshot types
Visual screenshot assertions
toHaveScreenshot() compares rendered pixels and supports the mask and maskColor options described here. It is part of the Playwright Test runner.
Generic snapshots
toMatchSnapshot() accepts strings, buffers and other serialized data. It is not the visual screenshot workflow; use toHaveScreenshot() when the subject is a rendered image.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
ARIA snapshots
ARIA snapshots represent accessible structure rather than pixels and use toMatchAriaSnapshot(). Screenshot masks do not apply to that representation. If the requirement is to verify accessible names, roles or relationships, write an ARIA assertion separately.
Rank #4
- 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
A complete test pattern
This example combines stable navigation, several locators, a visibility constraint and a component assertion:
import { test, expect } from '@playwright/test';
test('dashboard visual contract', async ({ page }) => {
await page.goto('https://example.com/dashboard');
await page.getByRole('heading', { name: 'Dashboard' }).waitFor();
const masks = [
page.getByTestId('rotating-message'),
page.getByTestId('current-user-time'),
page.locator('[data-testid="ad-slot"]').filter({ visible: true }),
];
await expect(page).toHaveScreenshot('dashboard.png', {
fullPage: true,
mask: masks,
maskColor: '#FF00FF',
});
const salesPanel = page.getByTestId('sales-panel');
await expect(salesPanel).toHaveScreenshot('sales-panel.png', {
mask: [salesPanel.getByTestId('live-total')],
});
});
Use page-wide and component-level assertions independently when they protect different contracts. Do not mask a region in a page test merely because it is difficult to stabilize if that region is itself important to the product’s visual behavior.
Troubleshooting mask failures
The overlay is missing
- Confirm that the locator matches the element at capture time.
- Check that the locator is scoped to the correct frame or component.
- Wait for the page state that creates the element before the assertion.
- Verify that the test is using
toHaveScreenshot(),page.screenshot()orlocator.screenshot(), not a generic snapshot matcher.
The overlay covers too much
The mask covers the complete bounding box. Replace a panel-level selector with a locator for the exact value or wrap the value in a dedicated test ID. This also reduces accidental masking of stable pixels.
A hidden duplicate is masked
Playwright masks invisible matches as well. Narrow the selector or add a visibility filter so only the intended rendered instance is selected.
The screenshot still changes between runs
Look for unmasked clocks, rotating content, animations, random data, delayed fonts, lazy images and network-dependent widgets. Mask only regions that are irrelevant to the assertion; stabilize important content through deterministic test data and explicit waits.
The baseline differs after changing maskColor
The overlay is part of the captured image. Changing maskColor necessarily changes the expected screenshot, so regenerate the baseline deliberately and review the diff.
Reliability and performance practices
- Use semantic or test-ID locators that survive CSS refactors.
- Keep masks narrow so visual regressions around the dynamic value remain visible.
- Reuse a consistent mask color and naming convention across the test suite.
- Prefer component screenshots for fast, focused checks and page screenshots for integration coverage.
- Keep page setup deterministic; masking should remove irrelevant variability, not conceal failures.
- Review any new mask as a test-design change: document why the region is intentionally excluded.
Or skip the browser setup
If you need an image of a URL rather than a Playwright visual assertion, ScreenshotNeo provides a website screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response reports the result in X-Page-Verdict and X-Billed headers. Its MCP tools—take_screenshot, get_page_info and capture_pdf—let Claude, Cursor and other MCP clients request captures.
Free tools Windows power users keep installed
One-click scans. No signup required.
See the ScreenshotNeo documentation for all options. A one-call cURL capture is:
Best Value
- 【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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request in Python:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
And in 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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo also supports full-page and selector captures, 12 device presets plus custom viewports, retina scale, dark mode, custom CSS and JavaScript, click and wait conditions, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API and an OpenAPI specification. Existing parameter names used by other screenshot APIs work as well.
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots; Growth is $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000 and Business $249 for 1,000,000. Yearly billing provides two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to start without a card.
FAQ
Does a mask alter the page that later test steps interact with?
No. The overlay belongs to the captured image; the DOM and the live page remain available to subsequent actions.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchCan I apply different colors to different masked elements in one assertion?
No. A screenshot capture has one maskColor value. If regions need different visual treatment, capture them separately or use separate assertions.
Bottom line
Put stable, narrowly scoped locators in mask: [...] on the page, locator or toHaveScreenshot() call. Remember that Playwright masks complete bounding boxes—including invisible matches—so refine selectors and add visibility constraints when necessary. Use visual screenshot assertions for pixels, and keep ARIA or generic snapshots as separate workflows.
Frequently Asked Questions
Does a mask alter the page that later test steps interact with?
No. The overlay belongs to the captured image; the DOM and live page remain available to subsequent actions.
Can I apply different colors to different masked elements in one assertion?
No. A screenshot capture has one maskColor value. Capture regions separately if they need different colors.
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 →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.

