If a cookie banner returns in every Playwright screenshot, check whether each screenshot uses a fresh browser context. A new non-persistent context does not inherit browsing data from an earlier one. Accept consent through the site once, save the resulting browser storage with Playwright, and load that state into the context used for the returning-visitor screenshot. If the screenshot is meant to show a first visit, keep the context clean instead.
Why the banner keeps coming back
Playwright browser contexts isolate browser state. A newly created non-persistent context starts without browsing data written by a previous run, so the site can treat it as a first-time visitor and show its consent banner again. This is expected behavior, not necessarily a screenshot bug. See the Playwright BrowserContext documentation.
Consent may be stored in a cookie, localStorage, sessionStorage, IndexedDB, or a consent manager’s other mechanism. There is no universal cookie name or storage key to add: inspect what the site actually writes after a visitor makes a choice.
Save consent once and reuse it
The reliable pattern is to make the real consent choice in the site UI, wait for that choice to be saved, take a storage-state snapshot, and provide the snapshot when creating the context for later screenshots. The following JavaScript example illustrates the documented Playwright APIs; replace the example URL and button locator with the target site’s details.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errors- Make the choice and save the state:
// Run once to create a post-consent state file. const context = await browser.newContext(); const page = await context.newPage(); await page.goto('https://example.com'); await page.getByRole('button', { name: /accept/i }).click(); // Save after the site's consent interface has committed the choice. await context.storageState({ path: 'consent-state.json' }); await context.close(); - Seed the screenshot context before visiting the page:
const returningVisitor = await browser.newContext({ storageState: 'consent-state.json', }); const screenshotPage = await returningVisitor.newPage(); await screenshotPage.goto('https://example.com'); await screenshotPage.screenshot({ path: 'page.png' }); await returningVisitor.close();
Playwright’s storageState() snapshot includes cookies and localStorage. IndexedDB can be included using the relevant option in versions that support it; check the documentation for the Playwright version installed in your project. The saved state is a snapshot, not a guarantee that every consent mechanism has been captured.
Diagnose the state the site actually uses
Check the context and timing first
Find where your screenshot test calls browser.newContext() and determine whether it creates a new context for every test or capture. A fresh context is isolated by design. Confirm that storage state is supplied when the context is created, before navigation, and save the state only after the consent interaction has completed.
#1 Best Overall
- [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
- [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
- [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
- [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
- [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)
Inspect cookies and localStorage
After accepting consent through the UI, inspect cookies for the site’s domain and localStorage for the current origin. Playwright documents cookie APIs such as browserContext.cookies() and browserContext.addCookies(), as well as WebStorage APIs for the current origin. Use inspection to discover the real values rather than guessing a key.
Scope matters: localStorage belongs to an origin, including scheme, host, and port. Cookies have domain and path scope, and may also have an expiry. A state captured for one host may not apply to a screenshot URL on another host or subdomain. Ensure the exact origin and cookie scope match the URL you visit.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- Model: Dell OptiPlex 7050 Small Form Factor (SFF)
- Processor: Intel Core i7-7700 3.60 GHz
- Memory: 32GB DDR4 Ram
- Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
- Operating System: Windows 11 Pro (64-bit)
Consider sessionStorage and IndexedDB
Playwright’s storage guide describes sessionStorage as session-scoped and cleared when the tab closes. If a banner disappears after consent but returns after closing the tab, sessionStorage may be involved. Ordinary cookie and localStorage snapshots may not reproduce that state. Inspect sessionStorage and any relevant IndexedDB or consent-manager behavior; do not assume a storage-state file includes every browser store.
Use separate tests for first visits and returning visitors
Make the intended visitor state explicit in the test. A first-visit test should use a clean context and assert that the banner appears. A returning-visitor screenshot should use a deliberate post-consent fixture. Depending on state accidentally left by another test makes screenshots harder to reproduce and can hide regressions in the banner itself.
- First visit: start without saved consent and verify the banner is visible.
- Returning visitor: load the post-consent storage state before navigation and verify the expected page appearance.
Troubleshoot by symptom
| What you see | Likely cause | What to check or change |
|---|---|---|
| The banner returns in each new test but disappears after clicking during that test. | Each test creates a fresh context without restored state. | Save a post-consent state and provide it to the screenshot context. |
| The state file has no consent cookie. | The site may store consent elsewhere, or the choice may not have been committed before saving. | Inspect current-origin WebStorage and other relevant stores after the UI interaction. |
| A cookie is present, but the banner still appears. | Cookie domain, path, or expiry may not match the tested URL, or the site may require additional state. | Compare cookie scope and the exact screenshot URL; inspect what else the consent manager stores. |
| The banner stays hidden on reload but returns after the tab closes. | Consent may rely on sessionStorage or other session-lifetime state. | Inspect sessionStorage and determine how the site expects that session state to persist. |
| The banner appears even with saved state. | State may be incomplete, loaded too late, scoped to a different origin, or checked remotely by the site. | Load state before navigation, verify the origin and saved values, and inspect console and network behavior. The specific cause depends on the site and test code. |
Or skip the browser setup
If you need a screenshot rather than a reusable Playwright test fixture, ScreenshotNeo is a website screenshot API and MCP server. Its capture flow accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, 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 other MCP clients.
For example, with an API key, one GET request captures a page as a WebP image:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →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 options. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for the free plan.
Rank #3
- IMMERSIVE 24 INCH DISPLAY: Experience stunning clarity on a Full HD IPS screen with ultra-thin bezels, offering a 90% screen-to-body ratio that makes everything from spreadsheets to streaming come alive with vibrant colors and crisp details.
- POWERFUL INTEL PROCESSING: Tackle demanding tasks with ease thanks to the Intel processor and 16GB of high-speed memory, delivering smooth performance whether you're multitasking between applications or running productivity software.
- GENEROUS STORAGE: Store all your important files, photos, and programs with blazing-fast solid state drive technology that ensures quick boot times, rapid file access, and plenty of space for your digital life.
- ENHANCED PRIVACY AND COLLABORATION: Work confidently with the pop-up privacy camera that tucks away when not in use, plus dual microphones with noise reduction for crystal-clear video calls that keep you connected professionally.
- ECO-CONSCIOUS DESIGN: Feel good about your purchase with an EPEAT Gold registered and ENERGY STAR certified computer that combines premium performance with responsible environmental manufacturing practices.
FAQ
Should I add a guessed consent cookie with Playwright?
No. First accept consent through the site and inspect the resulting state. Cookie names, values, scope, and storage mechanisms vary by site.
Will a saved storage-state file work for every website?
Not necessarily. It snapshots supported state such as cookies and localStorage, but a site can depend on sessionStorage, IndexedDB, another origin, or a server-side check. Verify the state against the target site and installed Playwright version.
Quick Recap
Best Value
- Connectivity: Includes WiFi, Bluetooth, and LAN for wireless and wired connections
- Memory: Features 16GB DDR4 RAM for smooth multitasking and performance
- Storage: Combines 500GB SSD and 1TB HDD for ample storage space
- Graphics: Integrated Intel UHD Graphics 630 for crisp visuals and video playback
- Design: Sleek desktop tower with black color and slim profile for modern look
Rank #4
- This Certified Refurbished product is tested and certified to look and work like new. The refurbishing process includes functionality testing, basic cleaning, inspection, and repackaging. The product ships with all relevant accessories, a minimum 90-day warranty, and may arrive in a generic box. Only select sellers who maintain a high-performance bar may offer Certified Refurbished products on Amazon.com.
- Dell Optiplex 3050 SFF Desktop computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD
- Includes: USB Keyboard & Mouse, USB WiFi adapter, Microsoft office 30 days free trail.
- Port: Front: USB 3.0(2), USB 2.0(2); Rear: DP, HDMI, USB 3.0(2), USB 2.0(2), RJ-45.
- Support 4K (3840x2160) Dual display, makes it easy to connect two monitors at the same time, and you can expand working Windows, mirror content, or expand a single window across multiple monitors.
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.

