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

To remove a cookie banner from a screenshot without accepting tracking, hide the banner with a narrowly targeted CSS rule at capture time. Do not click an accept button or preload a consent cookie. This changes the screenshot’s appearance; it does not reject consent or prove that tracking requests were blocked.

Hide the banner only while capturing

With Playwright, take the screenshot using its style option. Replace the example selector with one you have verified against the target page’s banner. Playwright documents that screenshot-time CSS is applied for the capture; it is not a consent action.

await page.screenshot({
  path: 'page.png',
  style: '.REPLACE_WITH_VERIFIED_BANNER_SELECTOR { display: none !important; }'
});

For example, if inspection confirms the banner container has the class .cookie-notice, use that specific selector instead of the placeholder. Avoid broad rules such as hiding every dialog or fixed-position element: they can remove unrelated page content. Check the resulting image to confirm that only the intended banner disappeared.

Use a clean browser context and avoid consent actions

  1. Create an isolated, non-persistent browser context. This prevents the capture from inheriting stored state from an earlier browser session. Playwright documents isolated contexts and browser-context cookie inspection and clearing methods at BrowserContext API.
  2. Load the page without clicking a consent control. Do not accept, reject, open preferences, or preload a consent cookie or saved consent state if the task is strictly screenshot-only cleanup.
  3. Inspect the page and identify its actual banner container. Markup varies by site, so there is no universal selector that can safely be assumed to work.
  4. Apply the verified selector in the screenshot call and capture the page.
  5. Review the image. Confirm that the banner was the only intended visual change and that useful page content remains visible.

For an authorized page, an isolated context helps keep the capture independent of previous browser state. It does not prevent the site’s own code from making network requests while the page loads.

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

Keep visual cleanup separate from consent and tracking

Method What it changes When to use it What it does not establish
Capture-time CSS What appears in the screenshot Remove a known banner from a visual capture It does not make or verify a consent choice, or show that tracking was blocked.
Reject or manage-preferences control The site’s consent interaction or state Test or exercise the site’s consent controls It is no longer screenshot-only visual cleanup.
Accept control The site’s acceptance interaction or state Test acceptance behavior only It conflicts with the goal of not accepting tracking.

A hidden banner does not mean consent was rejected, stored, or respected. Nor does a clean screenshot show whether cookies, pixels, or other tracking requests occurred. Treat tracking prevention or verification as a separate task involving browser storage and network behavior; the screenshot itself cannot answer that question.

Why clicking an “accept” example is different

Browserless’s cookie-consent example clicks an accept-like control before taking a screenshot: Browserless cookie-consent example. That approach may suit testing acceptance behavior, but it does not meet the requirement to remove a banner without accepting tracking.

Or skip the browser setup

ScreenshotNeo offers a screenshot API and MCP server. Its capture cleanup can accept the cookie or consent banner like a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. For this no-acceptance use case, configure the capture to hide the banner without selecting an accept action, and verify the output for the target site.

One GET request returns an image or PDF. For example, using cURL:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 request options. ScreenshotNeo reports page verdict and billing status in response headers; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Learn more at ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.

Troubleshooting

The banner is still visible

Check that the selector matches the rendered banner container, not merely a button or an obsolete class. The page may use different markup, or the banner may be inside an embedded frame. Inspect the actual page and test the selector again; the example selector is a placeholder, not a universal rule.

Page content disappeared too

Your selector may match a parent container or unrelated elements. Narrow it to the banner’s specific container and recapture. Confirm the affected content in the screenshot rather than assuming the selector is safe.

The screenshot looks clean, but tracking concerns remain

That is expected: hiding a visual element is not tracking prevention. Do not treat the screenshot as evidence about network requests, cookies, or consent state. Inspect or control those separately if they matter to your task.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

A consent banner was already absent

An earlier browser session may have stored state. Use an isolated, non-persistent context and avoid importing cookies or consent state. If the banner remains absent in a fresh context, the target page may simply not show it for that visit.

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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi