Use Playwright’s screenshot mask option to cover changing elements, or inject a capture-time stylesheet with style to hide or normalize them. For visual regression tests, put the mask or stylesheet on toHaveScreenshot. Disable animations separately when motion—not changing data—is causing image differences.
Mask a changing element with a locator
Pass one or more Playwright locators in the screenshot’s mask array. Playwright overlays each matched element’s bounding box; the default mask color is pink (#FF00FF). Use a stable test ID or a narrowly scoped semantic or CSS locator so you cover only the volatile region.
await page.screenshot({
path: 'page.png',
mask: [page.getByTestId('live-clock')],
});
To change the overlay color, set maskColor:
await page.screenshot({
path: 'page.png',
mask: [page.locator('.live-data')],
maskColor: '#cccccc',
});
The mask is a solid overlay, not a removal: the element’s box and layout remain, while its contents are obscured. Playwright also masks invisible matches. If invisible matching elements should not be covered, make the locator more specific or filter it to visible elements.
The Page API documents mask, maskColor, and their behavior. maskColor was added in Playwright v1.35; check the version installed in your project before using it.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Privacy Protection and Lens Care: Avoid private information from hacking while preventing dust-fall and scratching of the camera lens
- Multiple Compatibility: Suitable for Logitech webcam C920x, C920, C922, C930e, C922x Pro Stream HD Camera
- Artful Design: Modeled and designed exclusively to fit the above devices from Logitech and make it more stylish
- Easy Flip Mechanism: Can be turned 180 angle and easily take the cover off when flipping more than 180
- Simple Installation: Attaches securely to your Logitech webcam without leaving residue, allowing for quick and hassle-free setup
Hide or restyle content with capture-time CSS
Use the screenshot style option when hiding an element or changing its appearance is clearer than painting over its box. The stylesheet applies for the capture and can target content across Shadow DOM and inner frames.
await page.screenshot({
path: 'page.png',
style: '[data-volatile] { visibility: hidden !important; }',
});
Choose CSS deliberately: broad rules can conceal meaningful page content as well as volatile regions. Scope the selector to a test ID, data attribute, or other selector that identifies only the region you intend to normalize. The Page API’s style option was added in Playwright v1.41.
Use masks in visual regression assertions
When comparing a page against a stored baseline, pass the mask to Playwright Test’s toHaveScreenshot assertion. Screenshot assertions capture repeatedly until two consecutive screenshots are identical, then compare the result with the expected snapshot. The assertion API is a Playwright Test feature.
import { test, expect } from '@playwright/test';
test('page matches its visual baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot({
mask: [page.getByTestId('live-clock')],
});
});
For screenshot assertions, use stylePath to apply a stylesheet from a file rather than passing inline CSS. This is useful when a test suite shares the same volatility rules across captures.
Rank #2
- Privacy Protection: CloudValley webcam cover is designed for those who prioritize privacy, security, and peace of mind when using laptops, tablets, and computers
- Fashion Design: The space aluminum alloy webcam cover features a subtle design which compliments the beautiful aesthetic of top devices
- Ultra-Thin Design: Measures only 0.023 (0.6 mm) inch thin, ensuring it does not interfere with closing your laptop or device while providing reliable camera coverage
- Broad Compatibility: Works flawlessly with most laptops (MacBook, HP, Dell, Asus, Acer, Lenovo), All-in-One PCs and leading tablets including iPad, Surface Pro, Galaxy Tab, Fire HD, and Google Pixel Tablet
- Simple to Use: Only need to align to the webcam, attach and press it firmly for 15 seconds. Does not interfere with web use or indicator light
await expect(page).toHaveScreenshot({
stylePath: './tests/screenshot-styles.css',
});
See the Playwright screenshot assertions guide and the snapshot assertion API for assertion options. Thresholds and maximum differing-pixel settings change how much image difference is accepted; they do not remove dynamic content. Mask or restyle the actual changing region instead of using a looser comparison as a substitute.
Choose the right stabilization method
| Cause of screenshot differences | Use | Tradeoff |
|---|---|---|
| A small, well-defined region changes unpredictably | A locator in mask |
Preserves layout, but covers the visible content with a solid box. |
| Several elements should be hidden or visually normalized | style for a regular capture, or stylePath for an assertion |
Flexible CSS treatment; an overly broad selector can hide content you need to inspect. |
| Motion causes image differences | animations: 'disabled' |
Finite animations are fast-forwarded to completion; infinite animations are canceled at their initial state and resumed after capture. |
| A visual baseline is being checked | expect(page).toHaveScreenshot(...), or the locator equivalent |
Waits for two consecutive identical captures before comparison, but does not mask data that changes independently of animation. |
These methods address different causes. A clock that keeps changing needs a mask or CSS treatment even if animations are disabled; an animated element may need animation control even when its content is otherwise stable.
Control animations separately
Regular screenshot APIs default to animations: 'allow'. Set animations: 'disabled' to stop CSS animations, CSS transitions, and Web Animations during a capture. Finite animations are fast-forwarded; infinite animations are canceled to their initial state and resumed after the screenshot. Screenshot assertions disable animations by default.
await page.screenshot({
path: 'page.png',
animations: 'disabled',
});
Animation control does not stabilize changing timestamps, rotating ad content, or user-specific data. Combine it with a mask or stylesheet if those regions also vary.
Rank #3
- Note: Not suitable for MacBooks released after 2023 or devices with a protruding front camera; Not applicable to full-screen or notch-style tempered glass screen protectors; Do not use on the rear camera of the phone.
- 💻 Why Do You Need a Webcam Cover Slide? — Safeguard your privacy by covering your webcam with our reliable webcam cover when not in use. Don't let anyone secretly watch you. Stay protected!
- ✅ Thin & Stylish — Enhance your laptop's functionality and aesthetics with our 0.027" ultra-thin webcam covers. Seamlessly close your laptop while adding a touch of sophistication.
- ✅ Fits Most Devices — Compatible with laptops, phones, tablets, desktops! Keep your privacy intact on Ap/ple, Mac/Book, iPh/one, iP/ad, H/P, L/novo, De/ll, Ac/er, As/us, Sa/msung devices.
- ✅ 365 Days Protection — Our upgraded 3.0 adhesive ensures a strong hold that won't damage your equipment. Experience reliable, long-term privacy protection day in and day out.
Choose the capture scope
Match the capture scope to the region you need to inspect, and make sure the locator used for a mask refers to the intended content.
page.screenshot({ fullPage: true })captures the full scrollable page.locator.screenshot()captures one element; Playwright waits for actionability and scrolls the element into view.- Screenshot assertions also support page or locator captures.
For example, to capture a component without including unrelated page changes:
await page.getByTestId('summary-card').screenshot({
path: 'summary-card.png',
mask: [page.getByTestId('summary-card-clock')],
});
See the official screenshots guide for page and element capture behavior.
Version and option checks
Check the Playwright version in your project when using newer screenshot options. The Page API lists maskColor as available from v1.35, style from v1.41, and signal from v1.62. Use the API reference for the installed version when deciding whether an option is supported; do not assume a current documentation option exists in an older installation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #4
- 【Premium Webcam Cover】This webcam privacy cover is an accessory of computer webcam. No worry about interfering with web camera lens use or indicator light; No damage to your device in any way as well. A helpful privacy protector and dust separator
- 【Privacy Protector】Slide the web camera cover over your webcam lens when not in use, and prevents web hackers from Spying on you. It is perfect to provide privacy security and peace of mind to individuals, groups, organizations, companies and governments. It also protects your camera lens from dust, and keeps it in high-definition resolution all the ways
- 【Durable Material】The web cam cover is made of high-strength plastic, which ensures that your privacy is protected for a long and lasting period of time. The back of the web camera privacy cover slide also has a strong 3M adhesive layer. It helps the privacy protector stick firmly to your device. The most convenient, super thin design, and extra mini size, make it perfectly combine with your devices
- 【Wide Compatibility】This webcam cover is compatible with most popular webcams with flat area surrounding lens or with protruding lens, such as Logitech HD Pro Webcam C920 C920x C930e and C922, Logitech C615 and C270 (NOT fit Logitech C910, B910, C310). It can be also used as a cover for the peep hole on door
- 【For Logitech Webcam Cover】 The streamcam cover kit comes with 2 pack. Please clean the lens surface before applying. Make sure the mounting surface is cleaned completely so that it sticks properly and firmly
Troubleshoot inconsistent screenshots
The changing content still appears in the image
- Confirm the locator matches the element at screenshot time. A selector that is too narrow or does not match will not mask the intended region.
- Check whether the element is inside a frame or Shadow DOM and whether the locator targets the correct instance.
- For CSS hiding, verify that the injected rule is scoped correctly and uses sufficient specificity;
!importantcan override page styling when necessary.
Unexpected elements are masked
Playwright masks invisible locator matches too. Narrow the locator or filter it to visible elements when invisible matches should remain untouched.
The assertion still fails after animations are disabled
Animation control handles motion, not independent changes in page data or content. Identify and mask or restyle the changing area; comparison tolerance does not remove it.
The option is rejected or unavailable
Check the installed Playwright version against the option’s documented availability. In screenshot assertions, use stylePath for a stylesheet file; style is the capture-time option on regular screenshot APIs.
Or skip the browser setup
If you need a screenshot without setting up Playwright capture code, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns an image or PDF; this cURL example saves a WebP screenshot:
Best Value
- 【Protect Privacy Security】Focusing on network security, now we can easily and effectively protect personal and family privacy security , Just gently slide the slide and close the camera, you can stop the intrusion of hackers.
- 【 Ultra Thin Design】The new ultra-thin design, with a thickness of only 0.022 inches, is made of flexible ABS material and is not fragile. Will not affect the closing of the laptops and scratch the laptops.
- 【Easy to install】 Strong adhesive makes the cover not fall, keep the screen clean and free of stains during installation, tear off the adhesive tape on the back, align it with our camera, and press hard for 10 seconds to work.
- 【Compatible with 】Compatible with camera for Laptop, tablet, computers, Echo Show and Apple Devices,as: MacBook Pro,Macbook Air,iMac ,Mac mini,iPad,MacBook Air, iPhone 6/7/8 Plus etc front camera .
- [What you get] 6 pack black webcam covers.
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. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo and get 1,000 free screenshots a month with no card.
Frequently Asked Questions
Can I use a mask in a normal Playwright screenshot without Playwright Test?
Yes. Pass locator(s) in the mask option to page.screenshot() or a locator screenshot. toHaveScreenshot is the assertion feature that requires Playwright Test.
Does masking remove an element from the page?
No. It covers the matched element’s bounding box in the screenshot; use capture-time CSS when you want to hide or restyle it instead.
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.

