ScreenshotNeo

BlogHow-to

How to Remove a Cookie Consent Popup Before a Website Screenshot in India

Close a cookie consent popup before capturing a website screenshot. Learn the safe browser steps, what extensions can and cannot do, and how to automate repeat captures.

By the ScreenshotNeo team4 October 20266 min read

To remove a cookie consent popup before a website screenshot, use the site’s own consent controls first: choose an appropriate option such as “Reject optional,” “Necessary only,” or another preference the site offers, then confirm the banner closes before capturing. For repeat screenshots, a browser extension may handle some supported prompts, but hiding a banner is not the same as recording a consent choice. For automated captures, ScreenshotNeo can remove known consent banners before taking the shot.

The steps below apply when browsing from India as well as elsewhere. The available browser guidance does not establish India-specific legal requirements or how a particular Indian site must handle consent. If the question is legal rather than practical, consult a current primary Indian legal or regulatory source and assess the actual site.

1. Dismiss the popup using the site’s controls

  1. Wait for the consent interface to finish loading.
  2. Read the available choices. If appropriate, choose the site’s reject, necessary-only, or other preference control.
  3. Wait for the overlay to close and check that the content beneath it is visible.
  4. Capture the screenshot only after the page has settled.

Using a site control gives the site a choice through its own interface. Do not assume that clicking a particular control will persist the same way on every site; the reviewed guidance does not establish preference-retention behavior for individual websites.

2. Handle recurring prompts with care

A browser extension may help when you capture many sites. Extension behavior varies: it may submit a preference on supported prompts, hide the notice cosmetically, or leave unfamiliar forms untouched. Check what the extension does for the target prompt. A banner disappearing by cosmetic hiding does not prove that the site received or saved a preference.

Chrome’s third-party-cookie controls are separate from a site’s consent interface. Blocking third-party cookies is not a popup-dismissal method, and Chrome warns that blocking them can make some sites work unexpectedly. Deleting cookies is different again: Chrome notes that it may sign you out and remove saved preferences. Since clearing a saved preference can make a site ask again, clearing cookies is not a reliable way to stop a consent popup.

3. Inspect saved cookies in Chrome DevTools

Use DevTools when you need to inspect cookie state for an origin, not as a universal banner remover:

  1. Open the target page in Chrome.
  2. Open DevTools and select the Application panel.
  3. Under Storage, open Cookies and choose the site’s origin.
  4. Review the listed cookies. Delete one only if you understand that doing so can remove saved state, sign you out, or cause the site to show the prompt again.

DevTools documents viewing and deleting cookies for an origin. That capability does not promise to identify a site’s consent cookie or dismiss its overlay automatically.

4. Automate screenshots with Playwright

For a repeatable workflow you control, use the site’s actual consent button in your browser automation. The example below uses Node.js and Playwright. Replace the example URL and button labels with the target site’s details; there is no universal selector because sites implement consent dialogs differently.

import { chromium } from 'playwright';

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

try {
  await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });

  // Prefer a site-provided reject or necessary-only control when available.
  const consentChoice = page.getByRole('button', {
    name: /reject optional|necessary only|decline/i
  }).first();

  if (await consentChoice.isVisible().catch(() => false)) {
    await consentChoice.click();
  }

  // Wait for an overlay to disappear if this site exposes a stable selector.
  // Replace this selector with one inspected on the target site.
  const banner = page.locator('[data-cookie-banner]');
  if (await banner.count()) {
    await banner.waitFor({ state: 'hidden', timeout: 5000 }).catch(() => {});
  }

  await page.screenshot({ path: 'page.png', fullPage: true });
} finally {
  await browser.close();
}

Install Playwright in a project with npm install playwright. If the site’s control uses a link, a custom element, or a localized label, inspect the page and change the role, accessible name, or selector. Avoid blindly clicking an “Accept all” button: use the preference that reflects the visitor’s choice.

Persisting a choice across captures

When repeated captures should retain the same browser state, use a Playwright browser context or saved storage state after making the site’s choice. Keep that state scoped to the intended site and test it after the site changes. A stored browser state can expire or stop matching a site’s implementation; do not treat it as a permanent guarantee.

Why not just hide the overlay with CSS?

Hiding a banner with CSS can uncover the page visually, but it may leave the site without a recorded preference. Use that only when a visual-only cleanup is suitable for your task and document that it hides the interface rather than submitting a choice. For a faithful visitor-state capture, interact with the site’s own controls.

5. Troubleshoot common failures

What happens Likely cause What to try
The popup remains after clicking The click missed, the control label differs, or a second dialog appeared. Inspect the accessible name and element in DevTools or Playwright, then target the actual site control and wait for the overlay to close.
The automation cannot find the button The page has not rendered the prompt yet, the label is localized, or the control is inside a frame. Wait for the prompt, inspect its role and accessible name, and locate the relevant frame if needed. Use a site-specific selector.
The prompt appears again on the next run The choice may not have been saved, browser state was not reused, or the site cleared or changed its preference state. Verify the site’s behavior after choosing a preference. Reuse an appropriate browser context or saved storage state, and refresh that state when needed.
The page breaks after cookie settings change Blocking third-party cookies can affect site behavior; deleting cookies can remove login and preference state. Restore the previous browser setting or site state and use the site’s consent interface instead of changing browser-wide cookie settings.
The screenshot has a blank or covered area A different overlay, delayed content, or an incomplete page load may remain. Inspect the page before capture, wait for the relevant content or selector, and identify the specific overlay instead of assuming it is the consent banner.

6. Capture considerations for repeated work

  • Wait for the right state: wait for the consent choice and page content to settle before capturing. A fixed delay alone can be unreliable when site load times vary.
  • Keep state intentional: use a separate browser context for a clean session, or a deliberately saved state when you need the same visitor preference repeatedly.
  • Make selectors site-specific: button names, banner markup, and consent flows differ, including across language and viewport variations.
  • Do not infer consent from appearance: a hidden overlay only proves it is not visible in the screenshot.
  • Account for browser costs: browser automation requires a runtime, browser installation, and enough time and memory for navigation and rendering. For a handful of captures, manual dismissal may be simpler; for a repeated pipeline, automate and monitor failures.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. Make one request for a screenshot; its capture flow accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. AI agents can use its MCP tools, including take_screenshot, get_page_info, and capture_pdf.

See the ScreenshotNeo API documentation for request options. This example saves a WebP response:

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://example.com \
  -o shot.webp

There are 1,000 screenshots per month on the free plan with no card required; paid plans start at $5 for 3,000 screenshots. Sign up free and get 1,000 screenshots a month with no card.

Frequently asked questions

Will deleting cookies stop the banner from appearing?

It may do the opposite: deleting saved preferences can make a site ask again. It can also sign you out.

No. Some extension behavior is cosmetic, and support varies by prompt. Check whether the specific extension submits a choice or only hides the banner.

Does this guide establish what Indian law requires?

No. It explains browser and screenshot workflows. It does not settle India-specific legal requirements or the behavior of a particular website.

No universal selector or method covers every site. Site-specific automation may need adjustment, and automated cleanup services work according to their supported detection behavior.