Use an early navigation checkpoint, then take the screenshot immediately: start with Playwright’s waitUntil: 'commit' for the earliest capture, or try 'domcontentloaded' if the image needs more of the initial page. Neither guarantees the cookie banner will be absent; its timing depends on the site, so test the target page and choose the earliest point that still gives you the content you need.
Capture at an early navigation checkpoint
Playwright’s page.goto() can wait for different navigation milestones. The choice is a tradeoff: the earlier you capture, the less time the page has to render—and the less time a banner has to appear.
| Checkpoint | What it means | When to try it |
|---|---|---|
commit |
The response has been received and the document has started loading. | Use when avoiding a fast banner matters more than capturing a fully rendered page. The screenshot may be nearly empty or incomplete. |
domcontentloaded |
The document’s DOMContentLoaded event has fired. | Try when you need more of the initial document parsed. The extra time may also let banner code run. |
These milestone definitions come from the Playwright Page API documentation. It does not prescribe a universal delay that will beat every consent banner.
Runnable JavaScript example
Install Playwright and its browser first, for example with npm install playwright and npx playwright install chromium. Save this as an ES module, such as capture.mjs, then run node capture.mjs. Replace the example URL with the page you need.
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'commit' });
await page.screenshot({ path: 'before-banner.png' });
} finally {
await browser.close();
}
To let the initial DOM progress further, change 'commit' to 'domcontentloaded'. Capture promptly after goto() resolves; adding an arbitrary sleep creates more opportunity for delayed interface elements to appear.
Choose the checkpoint for the content you need
Start with commit if the site renders its banner quickly and the earliest possible capture is the priority. Inspect the image: a document that has only just begun loading may not yet contain useful visible content. If it is too incomplete, test domcontentloaded next. If a particular element must be present, wait for that element rather than for the whole network to become idle—but understand that the longer wait can give the banner time to appear.
There is no Playwright timing option that guarantees a banner-free screenshot across sites. A banner may be in the initial HTML or be added quickly by site JavaScript. Validate the result against the actual URL and run again if the site changes its behavior.
Use an init script only for deliberate page-side setup
page.addInitScript() evaluates a script after the document is created but before the page’s scripts run. Register it before navigation if you have a specific, tested page-side setup to perform early. The hook itself does not suppress cookie banners; any code that changes site behavior must be specific to the target and verified.
Recommended Free Tools
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.addInitScript(() => {
// Add tested, site-specific setup here only when needed.
});
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.screenshot({ path: 'before-banner.png' });
} finally {
await browser.close();
}
For setup shared across pages in a browser context, use browserContext.addInitScript(). It applies to pages in that context and relevant child-frame attachments or navigations. The BrowserContext API documentation warns that the evaluation order of context-level and page-level init scripts is undefined, so do not make one depend on running before the other.
When hiding the banner in the image is enough
If your goal is only to omit an element from the output image—not to stop consent code from loading—page.screenshot() has a style option that applies CSS during capture. For example:
#1 Best Overall
- 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.screenshot({
path: 'without-banner-in-image.png',
style: '.cookie-banner { display: none !important; }'
});
Replace .cookie-banner with a selector confirmed for the target page. This changes what the screenshot shows; it does not prove what a visitor would otherwise see or prevent the site’s consent behavior from running. See the Page API screenshot options for the documented capture controls.
Why not wait for network idle?
Playwright defines networkidle as no network connections for at least 500 ms and labels it “DISCOURAGED” for testing, recommending web assertions to assess readiness instead. That wait is also a poor default when the goal is to beat delayed UI: it can give a banner additional time to appear. Prefer an early navigation checkpoint or a specific readiness check tied to the content your screenshot requires.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshoot an early screenshot
- The image is blank or only partly rendered:
commitmeans the document has only started loading. Trydomcontentloaded, or wait for the specific content element you need and check whether the banner still appears during that wait. - The banner still appears: the site may include it in its initial HTML or run banner code before your capture. Test both documented checkpoints on that page; there is no guaranteed delay that works for every site.
- Your init script has no visible effect: confirm it is registered before navigation and that its setup is relevant to the target page. An init script is a timing hook, not a built-in banner remover.
- A context and page init script behave inconsistently together: their relative execution order is undefined. Combine dependent setup into one script or avoid relying on order.
- The screenshot hides an element but the site still behaves normally: that is expected when using the screenshot
styleoption; it changes the captured image, not the page’s consent logic.
Or skip the browser setup
ScreenshotNeo is a screenshot API and MCP server. A single GET request can return an image or PDF; its clean-shot options accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture, with each step configurable. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and responses identify the page verdict and billing status.
For a WebP screenshot of a page, replace the example URL as needed:
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. Its MCP server offers take_screenshot, get_page_info, and capture_pdf 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 free.
Rank #2
- 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
Frequently Asked Questions
Can Playwright guarantee a screenshot before every cookie banner appears?
No. Playwright documents navigation milestones, not when a particular site renders its consent UI. Test the target page and inspect the capture.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsQuick Recap
Best Value
- 【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.
Rank #4
- 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
Rank #3
- 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.
Does an init script automatically remove a consent banner?
No. It provides an early page-script hook; banner behavior must be handled with target-specific setup or another method.
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.

