First determine whether the “popup” is an HTML panel inside the page or a JavaScript browser dialog. Use Playwright locators for a consent banner, and capture it untouched if it should remain visible; click its actual control and verify the result if the screenshot should show the page after a choice. Handle JavaScript dialogs separately through Playwright’s dialog event. Then capture the intended state with page.screenshot().
Identify the popup and decide what the screenshot should show
A cookie or privacy banner is usually ordinary page content: an element in the page’s DOM that can cover or obscure other content. Inspect it and its controls, then decide the desired image before interacting:
- Show the consent notice: wait until the panel is visible and take the screenshot without activating a choice button.
- Show the page after a choice: locate the intended accept, reject, or preferences control, click it, verify the resulting page state, and capture afterward.
There is no universal consent-banner selector or button label. Markup and wording vary by site and may be localized. Prefer an accessible locator based on the observed role and name, such as getByRole('button', { name: 'Accept all' }), and adapt it to the page you are automating. Playwright’s Page documentation describes locators and page APIs.
In an automated test, clicking a control simulates interaction with the site; do not treat that action as a real person’s legal consent.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Capture the page with the consent panel visible
This Node.js example leaves the banner alone and captures it once it appears. Replace the URL and accessible name with those observed on the target page.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
try {
await page.goto('https://example.com');
const consentButton = page.getByRole('button', { name: 'Accept all' });
await consentButton.waitFor({ state: 'visible' });
await page.screenshot({ path: 'product-with-consent.png' });
} finally {
await browser.close();
}
})();
The button locator is used here only to establish that the panel is present; the script does not click it. If the panel has no suitable button, wait for an observed locator that identifies the panel itself instead.
As an Amazon Associate I earn from qualifying purchases.
Capture the page after a consent choice
When the intended image should show the page after a choice, click the site’s actual control and assert the expected result before capture. For example, if the banner disappears after acceptance:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
try {
await page.goto('https://example.com');
const acceptButton = page.getByRole('button', { name: 'Accept all' });
await acceptButton.waitFor({ state: 'visible' });
await acceptButton.click();
await acceptButton.waitFor({ state: 'hidden' });
await page.screenshot({ path: 'product-after-consent.png' });
} finally {
await browser.close();
}
})();
Change the final assertion if the site signals success in another way, such as displaying a confirmation or revealing a page element. An assertion tied to the expected UI state is more reliable than an arbitrary delay.
Handle JavaScript dialogs separately
A browser dialog created by JavaScript—alert, confirm, prompt, or a beforeunload prompt—is not an HTML consent panel. Playwright’s Dialogs documentation says dialogs are auto-dismissed by default when no dialog listener is installed.
#1 Best Overall
- Universal unlocked. Compatible with all major U.S. carriers, including Verizon, AT&T, T-Mobile and other prepaid carriers.
- Super-bright, super-smooth 6.7" display. See your screen clearly even outdoors in sunlight, and enjoy seamless views with a fast-refreshing 120Hz display.*
- AI-powered camera system. Take stunning photos in any light with the 50MP camera**, look your best with a 32MP selfie cam*****, and capture extreme close-ups.
- Superfast 5G performance. Unleash your entertainment at 5G speed*** with the MediaTek Dimensity 6300 chipset and up to 12GB of RAM with RAM Boost****.
- Long-lasting battery + TurboPower charging. Power through day after day with a 5200mAh battery, then get hours of power in just minutes.****
If the script needs to choose deliberately, register a handler before the action that triggers the dialog, and accept or dismiss it. A handler that only logs the message can leave the page action blocked.
page.on('dialog', async dialog => {
if (dialog.type() === 'confirm') {
await dialog.accept();
} else {
await dialog.dismiss();
}
});
// Perform the action that triggers the dialog only after registering the handler.
await page.getByRole('button', { name: 'Continue' }).click();
Choose the response that fits the test. Do not install this handler as a substitute for locating and interacting with an HTML banner.
Choose a browser context that matches the session you need
A fresh, non-persistent browser context is useful when the screenshot should reproduce a first visit without preferences from an earlier run. Playwright documents these contexts as isolated from other contexts and as not writing browsing data to disk. A new page created inside the context starts with that context’s session state.
Rank #2
- YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
- LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
- MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
- NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
- BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
If the screenshot must reflect a previously saved preference, use the appropriate saved state instead of assuming every run should be fresh. The right strategy depends on the behavior being demonstrated; consent storage and persistence are site-specific. See the BrowserContext documentation.
If clicking a link or control opens a new tab or window, wait for the popup event before the action and capture the returned page. The new page belongs to the opener’s browser context.
Rank #3
- Charger NOT Included, 6.7" Super AMOLED FHD+, 90Hz Refresh Rate, 385 ppi, 800 nits (HBM), 1080x2340px, 5000mAh Battery
- 128GB, 4GB RAM, microSDXC, Exynos 1330 (5nm), Octa-Core, Mali-G68 MP2 or Mali-G57 MC2 GPU
- Rear Camera: 50MP, f/1.8 (wide) + 5MP, f/2.2 (ultrawide) + 2MP, f/2.4 (macro), LED flash, panorama, HDR; Front Camera: 13MP, f/2.0, Android 14, up to 6 major Android upgrades, One UI 6.1
- 3G: HSDPA 850/900/1700(AWS)/1900/2100; 4G LTE: 1/2/3/4/5/7/12/13/14/20/25/26/28/29/30/38/39/40/41/48/66/71, 5G: 2/5/25/41/66/71/77/78 SA/NSA/Sub6/mmWave - Nano-SIM + eSIM
- US Model – Global Connectivity – Compatible with Most GSM Carriers like T-Mobile, AT&T, MetroPCS, etc. Will Also work with CDMA Carriers Such as Verizon, Straight Talk.
const popupPromise = page.waitForEvent('popup');
await page.getByRole('link', { name: 'Open product details' }).click();
const popup = await popupPromise;
await popup.waitForLoadState();
await popup.screenshot({ path: 'product-popup.png' });
Match screenshot options to the intended image
After the page reaches the state you want to document, use page.screenshot(). For example, await page.screenshot({ path: 'product.png' }) captures the viewport by default. The Page API also documents options that change what appears in the output:
fullPage: truecaptures the full scrollable page rather than only the viewport.maskcovers selected locators in the screenshot. Masking changes the image; it does not dismiss the banner, make a choice, or change the page state.
Use full-page capture or masking only when the intended deliverable calls for it. See the screenshot options and examples in the Playwright Page API.
Rank #4
- YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
- LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
- MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
- NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
- BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
Make the capture repeatable and diagnose failures
Wait for the expected UI, not all network activity
Use a locator assertion or wait that reflects the state you need—for example, the consent panel becoming visible or disappearing after a click. Playwright discourages networkidle as a testing readiness strategy; analytics and other background requests can make network activity a poor proxy for visual readiness.
Common problems and fixes
- The banner is not found: the selector or accessible name may not match the site, or the panel may not have appeared. Inspect the rendered page and use its actual structure and text; account for localization and session state.
- The screenshot still shows the banner after clicking: verify that the intended control was clicked and wait for the page’s actual post-choice state before capturing. A click completing does not by itself prove the UI changed as expected.
- A click or navigation stalls after a dialog appears: if a dialog listener is installed, ensure it calls
accept()ordismiss(). If no listener is installed, Playwright’s default is to dismiss dialogs automatically. - The screenshot hides the consent panel but the page still behaves as though it is present: a screenshot mask affects pixels only. Interact with the page control if the page state must change.
- The banner appears in one run but not another: check whether the run reuses a context or stored state. Use a fresh isolated context when the target is a first-visit view, or set up the saved state needed for a returning-session view.
- The screenshot is taken from the wrong tab: if the action opened a popup page, wait for the popup event and call
screenshot()on that returned page.
Or skip the browser setup
For a one-request screenshot without managing a Playwright browser, ScreenshotNeo is a website screenshot API and MCP server. Its API accepts a URL and can return an image or PDF. For a WebP screenshot of a product page, the cURL request is:
Best Value
- Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
- DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
- CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
- PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
- BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.
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 parameters and response details. ScreenshotNeo accepts cookie or consent banners as a visitor and removes 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 are not billed, and responses identify the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Quick Recap
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.

