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

The right way to stop a cookie banner covering an automated screenshot depends on what the image is supposed to prove. Keep it visible for a first-visit or consent-interface test. Establish the intended consent state for a returning-visitor test. Hide it only with capture-time CSS when you need a clean visual image—and label that image accurately, because hiding pixels is not the same as recording consent.

Choose the screenshot behavior before changing the page

Cookie banners represent different test conditions. Decide which one applies before writing automation:

Goal Correct treatment What the screenshot proves
First visit Leave the banner visible and assert that its text and controls appear. The consent interface renders for a new visitor.
Returning visitor Use the real consent flow or a controlled, documented fixture, then verify the resulting page state. The page behaves after consent has been established.
Clean visual capture Apply narrowly scoped CSS only while capturing. The underlying page layout, not a consent decision.

Do not call a visually hidden banner “accepted.” The browser state, cookies, local storage and server-side records remain separate from screenshot pixels.

Hide a known banner in a Playwright screenshot

Playwright’s page.screenshot() accepts a style stylesheet. The documentation says this stylesheet can hide dynamic elements and can reach Shadow DOM and inner frames, making it suitable for a capture-only overlay fix. Use a stable test ID, data attribute or accessible component selector rather than guessing from generic class names.

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

Minimal JavaScript example

import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage({
  viewport: { width: 1440, height: 900 },
});

await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({
  path: 'page-without-consent-overlay.png',
  fullPage: true,
  style: '[data-testid="cookie-banner"] { display: none !important; }',
});

await browser.close();

Replace data-testid="cookie-banner" with the selector used by the site. A selector such as [class*="cookie"] is risky: it may hide content, icons or scripts that merely contain the word “cookie.” Keep the rule limited to the consent component and, if necessary, its backdrop.

TypeScript with an explicit readiness check

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext({
  viewport: { width: 1366, height: 768 },
  reducedMotion: 'reduce',
});
const page = await context.newPage();

await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.locator('main').waitFor({ state: 'visible' });

const banner = page.locator('[data-testid="cookie-banner"]');
await page.screenshot({
  path: 'clean-capture.webp',
  type: 'webp',
  fullPage: true,
  animations: 'disabled',
  style: '[data-testid="cookie-banner"], [data-testid="cookie-backdrop"] { display: none !important; }',
});

await browser.close();

Use a page-specific readiness condition instead of assuming that networkidle means the content is complete. A page can continue polling, while an image can be visible before its final pixels arrive.

Keep the first-visit test honest

When the banner itself is under test, do not hide it. Start with a fresh browser context and assert the interface:

const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://example.com');

const banner = page.locator('[data-testid="cookie-banner"]');
await expect(banner).toBeVisible();
await expect(banner.getByRole('button', { name: /accept/i })).toBeVisible();
await page.screenshot({ path: 'first-visit.png', fullPage: true });

A fresh context avoids accidentally inheriting cookies or storage from an earlier test. Keep this assertion separate from your clean-capture test so a styling convenience cannot hide a regression in consent UI.

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

When should you click Accept?

For a returning-visitor scenario

Click the site’s actual control and then verify the state you rely on. For example, assert that the banner is hidden and that a consent cookie or application state has been set. The exact cookie name and selector are site-specific; there is no universal consent-manager selector.

await page.getByRole('button', { name: /accept all/i }).click();
await expect(page.locator('[data-testid="cookie-banner"]')).toBeHidden();
// Assert the site-specific post-consent state here.

For a first-visit experience

Do not click automatically. A click changes the scenario and can conceal a broken banner, inaccessible controls or incorrect copy.

For a visual-only image

Do not create a fake consent event merely to improve composition. Use the screenshot style option and record that the banner was hidden only for capture.

Masking is not removal

Playwright locator masking covers a matching locator’s bounding box with a mask color. It is useful when a region may remain visibly marked—for example, dynamic data in a visual comparison—but it does not remove the banner or reveal content underneath it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({
  path: 'masked.png',
  mask: [page.locator('[data-testid="cookie-banner"]')],
  maskColor: '#FF00FF',
});

Choose masking when the covered area is intentionally part of the comparison. Choose capture-time CSS when the deliverable must show the page without that overlay. Neither method establishes consent.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

Handling banners during interactions

A banner can intercept clicks before the screenshot step. Playwright documents locator handlers for unpredictable overlays. A handler can dismiss an overlay when that dismissal is genuinely part of the interaction scenario, but it should not replace a first-visit assertion or silently mutate the test’s purpose.

await page.addLocatorHandler(
  page.locator('[data-testid="cookie-banner"]'),
  async (locator) => {
    await locator.getByRole('button', { name: /reject/i }).click();
  },
);

Prefer an explicit setup step when the consent state matters. Handlers are most useful for incidental overlays that may appear while the test performs unrelated actions.

Can Puppeteer do this too?

Yes, Puppeteer supports page screenshots and element screenshots. Its guide documents ElementHandle.screenshot(), which attempts to scroll a hidden element into view before capture. The cited guide does not describe a dedicated cookie-banner-hiding option, so use the site’s test state or inject narrowly scoped capture CSS, then verify the result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 900 });
await page.goto('https://example.com', { waitUntil: 'networkidle0' });
await page.addStyleTag({
  content: '[data-testid="cookie-banner"] { display: none !important; }',
});
await page.screenshot({ path: 'puppeteer-clean.png', fullPage: true });
await browser.close();

See the Playwright Page API, Playwright TestOptions and Puppeteer screenshots guide for the documented capture APIs.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Make screenshots repeatable

Banner handling is only one source of visual differences. Control the following inputs:

  • Viewport: Fix width, height and device scale factor. A responsive banner can change position at a breakpoint.
  • Capture mode: Decide between viewport and full-page capture. Full-page screenshots can expose sticky banners that are not visible in the initial viewport.
  • Readiness: Wait for a meaningful selector, a known delay or the application’s own ready signal.
  • Motion: Disable or reduce animations and transitions so a fade-in banner is not caught halfway through.
  • Dynamic content: Freeze clocks, random data, rotating carousels and live counters where your test permits.
  • State: Use isolated contexts and explicit cookies or storage fixtures. Do not depend on whichever consent state a previous test left behind.
  • Frames and Shadow DOM: Scope selectors carefully; capture styles can reach these boundaries, so an overbroad rule can hide unrelated components.

Troubleshooting common failures

The selector matches nothing

Inspect the live DOM after navigation. The banner may be inside an iframe, Shadow DOM, a consent vendor’s changing markup or a delayed component. Prefer a stable attribute supplied by the application. Add a wait for the component only when its presence is part of the expected scenario.

The banner still covers the image

Check whether a backdrop, parent wrapper or fixed sibling remains. Add only those known selectors to the capture stylesheet. For an iframe, identify the frame and verify that your selector targets the component rather than the frame element itself.

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

Content disappears with the banner

Your selector is too broad. Remove class-substring rules and target a unique ID, test attribute or component root. Compare a screenshot without the style to confirm what the rule removes.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

The screenshot is clean but the test is invalid

You probably hid the banner in a test intended to validate first-visit behavior. Separate visual cleanup from consent assertions and start that test in a fresh context.

Clicks fail before capture

The overlay is intercepting pointer events. Establish the intended consent state before interacting, or use a documented locator handler for an incidental overlay. Avoid deleting arbitrary DOM nodes or blocking all consent-related network requests; those changes can alter page behavior.

Images or page sections are missing

Wait for the application’s content-ready condition, scroll or trigger lazy loading when required, and use the same viewport and full-page setting on every run. Network-idle alone is not a universal guarantee of visual completeness.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a hosted website screenshot API and MCP server. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP tools—take_screenshot, get_page_info and capture_pdf—let Claude, Cursor and other MCP clients capture pages without your own browser setup.

Use the API documentation at screenshotneo.com/docs/ for options such as full-page capture, a CSS selector element, dark mode, device presets, custom CSS and JavaScript, clicks, waits, blocked requests, headers, cookies, user agents, timezone, geolocation, resizing, caching, signed links, asynchronous webhooks and bulk capture.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

There are 1,000 screenshots per month free with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan. Create a free ScreenshotNeo account.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

FAQ

Does hiding a cookie banner satisfy privacy requirements?

No. It changes the captured pixels only. Consent requirements depend on the site, jurisdiction and how the application records user choices.

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

Should I hide banners in visual regression baselines?

Only if the baseline intentionally represents a clean, non-consent view. Keep a separate first-visit assertion so the consent interface remains covered by tests.

Can one selector work on every website?

No. Consent managers use different markup, frames, Shadow DOM and state mechanisms. Maintain site-specific selectors or fixtures.

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.