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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use a selector that matches the target site’s real consent button, click it with a Puppeteer locator, wait for the site to show that consent has taken effect, then capture with fullPage: true. There is no universal cookie-accept selector or post-click wait condition: inspect the page and choose evidence that fits its behavior.

Install Puppeteer and prepare a page

In a Node.js project, install Puppeteer with npm install puppeteer. This example opens a page, accepts a consent button by its accessible name, waits for the dialog to disappear, and saves a full-page PNG. Replace the URL, selector, and confirmation condition with ones verified on your target website.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });

    // Illustrative only: use this accessible name only if the page exposes it.
    const consentButton = page.locator('::-p-aria(Accept all cookies)');
    await consentButton.click();

    // Replace with an observable, site-specific confirmation.
    await page.locator('[role="dialog"]').waitFor({ state: 'hidden' });

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

Puppeteer’s Page interactions guide recommends locators for selecting and interacting with elements. Locators wait for action preconditions including visibility, enabled status, viewport presence, and a stable bounding box. See the Page interactions guide and confirm details against the Puppeteer version installed in your project; the consulted documentation references version 25.12.0.

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

Find the consent control that actually exists

Cookie-consent interfaces vary by site. First inspect the rendered page and determine the button’s accessible name, text, or DOM selector. A selector such as ::-p-aria(Accept all cookies) is only suitable when that exact accessible name is exposed; it is not a general-purpose cookie selector.

#1 Best Overall
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.
  • Prefer an accessible name or text when it clearly identifies the intended action and is stable on the site.
  • Use a CSS selector when the site provides a reliable, specific element or attribute.
  • Check for multiple matching buttons: a locator should identify the intended consent action, not an unrelated “accept” control.
  • If the control is inside an iframe or shadow root, identify that context and use Puppeteer’s frame or deep-selector support as appropriate.

A generic selector may fail when markup differs, when the control has not appeared yet, or when it matches the wrong element. Puppeteer documents that page.click(selector) throws if no element matches and clicks the first matching element if several do. See the Page.click API.

Click and wait for the right outcome

Clicking does not itself prove that consent was accepted. Choose a visible result that is meaningful for the specific page, such as the consent dialog becoming hidden, a consent panel being removed, or a known page element changing. There is no universal Puppeteer cookie-consent wait condition.

When the click triggers navigation

Start the navigation wait and the click together so the navigation cannot complete before Puppeteer begins waiting for it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Apple 2026 MacBook Air 13-inch Laptop with M5 chip: Built for AI, 13.6-inch Liquid Retina Display, 16GB Unified Memory, 512GB SSD, 12MP Center Stage Camera, Touch ID, Wi-Fi 7; Midnight
  • BUILT FOR COLLEGE. AND BEYOND — MacBook Air with the M5 chip packs blazing speed and powerful AI capabilities into an incredibly portable design. And with up to 18 hours of battery life,* this thin and light powerhouse is ready to take on almost any major, just about anywhere.
  • TEAR THROUGH TOUGH ASSIGNMENTS — With its faster CPU and unified memory, the M5 chip delivers even more performance and fluidity across apps, making multitasking and creative workflows smooth and responsive. A powerful Neural Engine and next-generation GPU with Neural Accelerators give you a powerful platform for AI.
  • MAKE QUICK WORK OF YOUR TO-DO LIST — Apple Intelligence helps you write, express yourself, and get things done effortlessly — whether it’s for school or everyday life. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*
  • UP TO 18 HOURS OF BATTERY LIFE — MacBook Air delivers incredible battery life with amazing performance, so you can power through a full day of classes without worrying about plugging in.
  • A BRILLIANT 13.6-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Air supports 1 billion colors, making photos and videos pop with rich contrast and sharp detail, and text appears supercrisp. So everything — from class presentations to movies to games — looks truly stunning.
const selector = '::-p-aria(Accept all cookies)';
const [response] = await Promise.all([
  page.waitForNavigation(),
  page.locator(selector).click(),
]);

This is the documented race-avoidance pattern for a click followed by navigation; adapt it to the chosen locator and the site’s expected behavior. If the interaction does not navigate, do not wait for navigation—wait for a page-specific observable state instead. Details are in the Page.click API.

When there is no navigation

Wait on a condition that the page actually changes. For example, if the site hides a dialog after acceptance, a locator wait can observe that:

await page.locator('[role="dialog"]').waitFor({ state: 'hidden' });

Use this only if the target’s consent interface is represented by that dialog selector. Otherwise, substitute a selector or condition supported by the site’s DOM. The confirmation is workflow logic for your target, not a built-in guarantee that Puppeteer has accepted cookies.

Rank #3
HP OmniBook 3 17.3 inch Laptop PC, FHD Display, AMD Ryzen 3 30, 8 GB RAM, 512 GB SSD, AMD Radeon 610M Graphics, Windows 11 Home, Mica Silver, 17-dp0199nr
  • FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
  • AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
  • ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
  • AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
  • STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth

Capture the whole page

After consent has taken effect, capture with fullPage: true:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({ path: 'page.png', fullPage: true });

The screenshot option fullPage captures the full page when true; its default is false. Without it, the screenshot is limited to the viewport. See ScreenshotOptions.

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

Or skip the browser setup

If you do not want to configure Puppeteer, ScreenshotNeo offers a website screenshot API and MCP server. A single request can return a screenshot or PDF; its consent handling accepts cookie banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers indicate the page verdict and billing status. AI agents can use its MCP tools, including take_screenshot, get_page_info, and capture_pdf.

Example cURL request:

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

See the ScreenshotNeo API documentation for request parameters and response details. ScreenshotNeo offers 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Sign up for the free plan.

Rank #4
Dell 15.6 Laptop, FHD, Intel Core 3 100U, 8 GB RAM, Windows 11 Home
  • Effortlessly chic. Always efficient. Finish your to-do list in no time with the Dell 15, built for everyday computing with Intel Core 3 processor.
  • Designed for easy learning: Energy-efficient batteries and Express Charge support extend your focus and productivity.
  • Stay connected to what you love: Spend more screen time on the things you enjoy with Dell ComfortView software that helps reduce harmful blue light emissions to keep your eyes comfortable over extended viewing times.
  • Type with ease: Write and calculate quickly with roomy keypads, separate numeric keypad and calculator hotkey.
  • Ergonomic support: Keep your wrists comfortable with lifted hinges that provide an ergonomic typing angle.

Troubleshoot common failures

The selector does not match

Inspect the actual rendered page and verify the button’s accessible name, text, and DOM location. If it is in a frame or shadow root, select it through the appropriate context rather than assuming it is in the main document.

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

The click throws or hits the wrong button

A missing selector causes an error; multiple matches mean page.click selects the first. Make the selector specific enough to identify the intended consent action, and check that the control is available before interacting.

The screenshot still contains the banner

Do not take the screenshot immediately after issuing the click. Wait for a site-specific state change that confirms the banner is hidden or consent has been applied; the right signal depends on the site.

The script times out waiting for navigation

The click may not navigate. Use a state-based wait instead, such as the relevant dialog becoming hidden. When navigation is expected, start the navigation wait concurrently with the click using Promise.all.

The capture shows only the visible screen

Set fullPage: true in the screenshot options. Its default is false.

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.

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.