Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →To hide a page element in a Playwright screenshot, inject a CSS rule through the screenshot call’s style option—for example, .cookie-banner { display: none !important; }. Replace the example selector with one that matches the element on your page. For a one-off capture, you can instead inspect the element in Chrome DevTools, apply the rule temporarily, and take the screenshot while it is active.
Choose the right approach
| Method | Best for | What appears in the image |
|---|---|---|
| Chrome DevTools CSS edit | A one-off screenshot or identifying the right selector | The element is hidden by the rule you apply |
Playwright style |
A scripted screenshot capture | The injected CSS changes the capture composition |
Playwright stylePath |
Reusable rules in screenshot assertions | The stylesheet filters dynamic or volatile content |
Playwright mask |
Covering a region without hiding it through CSS | A colored overlay covers the matched locator bounds |
Find a selector that matches the element
- Open the page in Chrome. Right-click the element you want to hide and choose Inspect, or open DevTools’ element picker and click the element.
- In the Elements panel, inspect the selected node and identify a selector that targets it, such as a meaningful class or ID present in the markup.
- Check that the selector targets the intended element rather than a larger page region or several unrelated elements. A class or ID you can confirm in the markup is generally easier to maintain than a selector based on an element’s position.
For example, if the inspected element has the class cookie-banner, the rule .cookie-banner { display: none !important; } hides it. That class is only an example; websites use different markup, so verify the selector on the page you are capturing.
Hide an element in Chrome DevTools for a one-off capture
- Inspect the element and confirm its selector as described above.
- In DevTools, edit or add a CSS declaration for the selected element, such as
display: none !important;. Alternatively, add a rule for the selector in the Styles pane. - Confirm that the intended element disappears without hiding anything else you want in the image.
- Capture the screenshot while the rule is active.
This is a temporary DevTools edit for the inspection session; it does not save a change to the website’s source. If the page reloads or you need repeatable captures, use a scripted screenshot rule instead.
Hide an element in a Playwright screenshot
Playwright’s Page screenshot API supports the style option for CSS applied during screenshot capture. It was added in Playwright v1.41. The documentation says injected styles pierce Shadow DOM and apply to inner frames. Adapt this runnable example to a page you can access and a selector that matches its rendered markup:
Recommended Free Tools
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({
path: 'page.png',
style: '.cookie-banner { display: none !important; }'
});
await browser.close();
})();
Replace https://example.com and .cookie-banner with your target page and its actual selector. The networkidle wait is an example choice, not a requirement; pages with ongoing network activity may need a different readiness condition. See Playwright’s Page API documentation for the screenshot options and current API details.
Reuse CSS in Playwright screenshot assertions
For visual tests, put screenshot-specific rules in a stylesheet and pass its path to toHaveScreenshot:
await expect(page).toHaveScreenshot({ stylePath: './screenshot.css' });
For example, screenshot.css can contain iframe { visibility: hidden !important; } if hiding iframes is appropriate for that test. Playwright documents stylePath as a way to filter dynamic or volatile content so screenshots are more deterministic. See Playwright’s test snapshots documentation.
#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.
Hide with CSS or cover with a mask?
Use CSS when the element should disappear
A rule such as display: none removes the element from the visible composition. This is suitable when you want the screenshot to show no banner, popup, or other targeted element.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use a mask when a colored cover is acceptable
Playwright’s screenshot API can mask matched locators with a colored overlay (pink by default, or a custom mask color). The covered region remains a colored block in the image; it is not the same result as hiding an element with CSS.
Neither CSS hiding nor a visual mask establishes that underlying page data has been deleted or securely redacted. Do not use either as a guarantee that sensitive content is unrecoverable.
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.
Troubleshoot selectors and capture results
- The element remains visible: Reinspect the rendered element and confirm the selector matches it. Check for a typo, a different class or ID, or markup that changes after the page loads. Keep
!importantin the rule when existing styles override the declaration. - The rule hides too much: The selector may match multiple elements or a parent containing other content. Inspect its matches and narrow the selector before capturing.
- The DevTools edit is gone: DevTools changes are temporary. Apply the rule again, or move it into Playwright’s
styleoption or a reusablestylePathstylesheet. - The screenshot test still varies: Identify the changing element and filter only that content with a test stylesheet. Broad rules can make a test pass while concealing meaningful page changes.
- You see a colored block instead of an empty area: That is mask behavior. Use a CSS hiding rule if the element should disappear from the composition.
Or skip the browser setup
ScreenshotNeo can apply a CSS selector to an element capture, alongside options such as custom CSS and JavaScript. For a straightforward screenshot, one GET request returns an image or PDF. The example saves the response as a file; check the returned content type or configure the requested format when you need a specific output.
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 authentication and selector options. ScreenshotNeo accepts cookie or 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, blank pages, timeouts, failed loads, and cache hits are not billed, and responses say which page verdict and billing status applied. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Free tools Windows power users keep installed
One-click scans. No signup required.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Quick Recap
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.
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
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.
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.

