October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Puppeteer: Click Accept Cookies Before Taking a Full-Page Screenshot

A practical Puppeteer workflow for clicking a site-specific cookie control, confirming consent has taken effect, and capturing the full page.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Puppeteer’s locator API to click the consent control your target page actually exposes, wait for a site-specific sign that the consent interface is gone, then call page.screenshot({ fullPage: true }). There is no universal cookie-button selector or universal signal that consent has completed, so inspect the page and tailor both to its DOM.

Inspect the consent control before choosing a selector

Different sites use different button text, markup, frames, and shadow roots. First inspect the target page in a browser or examine its DOM and accessible labels. Choose a locator that identifies the intended action on that page, not a selector copied from another site.

As an Amazon Associate I earn from qualifying purchases.

Puppeteer’s Page interactions guide recommends Locators for selecting and interacting with elements. Locators wait for action preconditions including the element being present, visible, enabled, in the viewport, and at a stable bounding box. See the Puppeteer Page interactions guide.

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

If the page exposes the accessible name “Accept all cookies,” for example, you can use:

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
await page.locator('::-p-aria(Accept all cookies)').click();

That is an example, not a universal selector. If the actual accessible name differs, use the name you found. Puppeteer also supports CSS, text, XPath, and deep selectors; choose one that matches the page reliably. If the control is inside a frame or shadow root, locate it in the appropriate context using Puppeteer’s frame or deep-selector support.

Click, confirm the page state, and capture the full page

This CommonJS example shows the sequence. Replace the URL, consent locator, and post-consent condition with values that match your target site. The example assumes the consent dialog disappears without navigating; its condition is intentionally site-specific.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
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' });

    // Use the accessible name actually exposed by the target page.
    await page.locator('::-p-aria(Accept all cookies)').click();

    // Replace this selector and condition with an observable page-specific
    // indication that consent has completed (here: the dialog is removed).
    await page.waitForFunction(() => {
      const dialog = document.querySelector('[role="dialog"]');
      return !dialog || !dialog.isConnected ||
        getComputedStyle(dialog).display === 'none' ||
        getComputedStyle(dialog).visibility === 'hidden';
    });

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

The sample condition only checks a generic dialog and is not proof that consent was saved. On a real target, identify a more specific signal when possible, such as the actual banner disappearing or a site-specific state change. Do not take the screenshot immediately after the click if the page is still changing.

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

If clicking triggers navigation, start the navigation wait and click together so the wait cannot miss a fast navigation:

const [response] = await Promise.all([
  page.waitForNavigation(),
  page.locator('::-p-aria(Accept all cookies)').click(),
]);

Use this only when that click is expected to navigate. If it does not navigate, wait for the relevant non-navigation outcome instead. Puppeteer’s Page.click API documents the navigation race and the concurrent-wait pattern. A missing selector causes an error; the API also notes that selector-based clicking targets the first match when several elements match. Prefer a locator that uniquely identifies the intended control.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Finally, fullPage: true captures the full page rather than only the current viewport; the screenshot option defaults to false. See Puppeteer ScreenshotOptions.

Troubleshoot common failures

  • Locator finds no button: Check the actual accessible name and DOM after navigation. The button may be in a frame or shadow root, or may appear only after a delay. Select it in the correct context rather than assuming the example name exists.
  • Click errors or times out: Confirm the matching element exists and is enabled and visible. If several controls match, narrow the locator so it targets the intended button.
  • Screenshot still contains the banner: A successful click does not guarantee consent completed. Wait for a target-specific visible state change; revise the condition if the site hides, replaces, or retains the dialog.
  • Navigation wait hangs or times out: The click may not navigate. Use a navigation wait only for a click expected to navigate; otherwise wait for a site-specific state change.
  • Screenshot shows only the first screen: Pass { fullPage: true }; without it, the full-page option is false by default.
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 provides a screenshot API and MCP server. Its capture can accept cookie and consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before taking the shot; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with the response identifying the page verdict and billing status. AI agents can use its MCP server tools to take screenshots, get page information, and capture PDFs.

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.

One GET request returns an image or PDF. For example, this cURL call saves a WebP screenshot:

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
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 documentation for the API details. Free includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.