Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To remove a cookie banner from a Selenium screenshot, first decide whether your test needs to exercise the site’s consent flow or only produce a clean image. For a realistic test, click the site’s own accept, reject, or preferences control and wait for the banner to disappear. For repeatable tests, initialize the site’s observed consent state before loading the page. For a visual-only screenshot, hide or remove the rendered banner after inspecting its actual selector—and check for leftover overlays or scroll locks.
Choose the method that matches the test
There is no universal Selenium cookie name, consent value, or banner selector. Consent behavior is defined by each site, and its state may be stored in a cookie or another browser storage key. Inspect the target site rather than guessing. The three methods below differ in what they test and what can go wrong.
| Method | Best for | Main trade-off |
|---|---|---|
| Click a consent control | Testing the user-visible consent flow | Depends on the banner and its controls rendering reliably |
| Initialize observed consent state | Repeatable runs that should start with a known choice | Depends on site-specific storage details |
| Hide or remove the rendered banner | A clean visual artifact when consent behavior is not under test | Can leave a backdrop, scroll lock, or focus trap behind |
Prepare a repeatable Selenium run
Start from a clean browser session when the test requires predictable first-visit behavior. If a prior run has already stored consent, the banner may not appear, so a test that expects to interact with it can silently stop exercising that path. Keep a separate test that verifies the genuine consent interaction if the suite also needs to check the site’s consent behavior.
Free tools Windows power users keep installed
One-click scans. No signup required.
Before using Selenium’s cookie API to add a domain cookie, navigate the browser to that cookie’s domain. Selenium operates on the current browsing context and documents that the browser must be on the domain for which the cookie is valid. If the homepage is slow or large, Selenium’s documentation suggests navigating first to a smaller page on the same site. See the Selenium WebDriver cookie documentation.
Method 1: click the real consent control
Use the site’s own accept, reject, or preferences control when your test is meant to model a user decision. This lets the site’s code apply the state it expects, rather than having the test invent a cookie value. Inspect the page to identify the actual control and substitute its selector in the example. The example uses Python Selenium and waits for the banner to become invisible before saving the screenshot.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = "https://example.com/page"
banner_selector = "#cookie-banner" # Inspect and replace
accept_selector = "button.accept-cookies" # Inspect and replace
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
try:
driver.get(url)
wait = WebDriverWait(driver, 15)
banner = wait.until(
EC.visibility_of_element_located((By.CSS_SELECTOR, banner_selector))
)
wait.until(
EC.element_to_be_clickable((By.CSS_SELECTOR, accept_selector))
).click()
wait.until(EC.invisibility_of_element(banner))
driver.save_screenshot("page.png")
finally:
driver.quit()
Replace the example URL and both selectors with values from the target page. If the banner can be absent because consent was already stored, make that an explicit test case rather than allowing a timeout to obscure whether the interaction path ran. A click is the most representative approach, but it tests the UI as well as the screenshot and may require site-specific handling when controls differ by locale or page.
Method 2: initialize the consent state the site actually uses
This approach is useful when every run should begin with a known choice without repeating the banner interaction. First make the choice once through the page UI, then inspect what the site stored. Chrome DevTools provides cookie inspection and editing under Application > Storage > Cookies; its documentation also explains that cookies are used for session management, personalization, and tracking, and can be the cause of cookie consent forms. See Chrome DevTools: View, add, edit, and delete cookies.
After identifying the actual cookie, you can establish that observed value before navigating to the screenshot target. Do not copy a made-up cookie name or value from another site. The placeholder below must be replaced with the real cookie name, value, and domain attributes found for your target.
from selenium import webdriver
base_url = "https://example.com/"
target_url = "https://example.com/page"
observed_cookie = {
"name": "REPLACE_WITH_OBSERVED_NAME",
"value": "REPLACE_WITH_OBSERVED_VALUE",
"domain": "example.com",
"path": "/",
}
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
try:
# The browser must first be on the cookie's domain.
driver.get(base_url)
driver.add_cookie(observed_cookie)
# Load the page whose screenshot you need after setting the state.
driver.get(target_url)
driver.save_screenshot("page.png")
finally:
driver.quit()
Selenium also supports retrieving and deleting a named cookie, or deleting all cookies, in the current browsing context. Clearing cookies is useful when you need to restore a first-visit condition; it does not establish a consent choice. The official cookie page documents these operations and the domain requirement: Selenium cookie operations.
Some sites use a storage key other than a cookie. In that case, identify the site’s real behavior through a known consent action and use the site’s actual mechanism; Selenium’s cookie API cannot set an arbitrary non-cookie storage value. Treat site storage as implementation detail that can change, and verify the resulting page state before capturing.
#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
Method 3: hide or remove the rendered banner
If the goal is only a clean image—not a test of consent behavior—you can alter the page after it loads. Inspect the banner and any backdrop first. The JavaScript below demonstrates hiding an inspected selector; replace the selector and ensure the page has rendered the banner before executing it.
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 →from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = "https://example.com/page"
banner_selector = "#cookie-banner" # Inspect and replace
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
try:
driver.get(url)
banner = WebDriverWait(driver, 15).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, banner_selector))
)
driver.execute_script(
"arguments[0].style.setProperty('display', 'none', 'important');",
banner,
)
driver.save_screenshot("page.png")
finally:
driver.quit()
Hiding a banner is different from accepting or rejecting consent. It changes presentation for the screenshot but may leave the page in a state where scrolling is disabled, a transparent backdrop blocks content, or keyboard focus remains trapped. Inspect the screenshot and interact with the page if necessary to check that the underlying content is in the intended visual state. Removing a DOM node instead of hiding it has the same limitation: it does not necessarily undo other page behavior triggered when the banner appeared.
Inspect consent cookies with Chrome DevTools
- Open the target page in Chrome and bring up DevTools.
- Open Application > Storage > Cookies and select the target site’s origin.
- Record the relevant cookie state before and after making the intended choice through the site’s UI.
- Use the observed name and value in the test; do not infer them from a different site.
- Check whether the site also uses third-party cookies or another storage mechanism if the observed state does not explain the banner behavior.
Chrome’s Application and Network inspection can identify third-party cookies as well. The relevant UI and cookie behavior are described in Google’s DevTools cookie guide.
Save the screenshot only after the intended state is reached
For the click approach, wait until the consent UI is no longer visible before capturing. For state initialization, load the target page after setting the observed state and verify that the banner is absent. For visual-only removal, confirm that no backdrop or other blocking UI remains. Selenium’s Python WebDriver API reference documents screenshot-related methods such as saving a screenshot: Python WebDriver API reference.
The example code writes a PNG using Selenium’s browser screenshot API. If the consent action opens a preferences panel or requires a second confirmation, wait for the final intended state—not merely the first click—before saving. A screenshot taken while a transition or overlay is still active can look like a failed removal even when the stored state is correct.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRank #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
Troubleshooting common failures
The cookie cannot be added
Navigate to the cookie’s domain before calling add_cookie. Check that the observed cookie’s domain and path match the target, and avoid guessing a domain attribute.
The banner returns on every run
Confirm that the test applied the same state the site’s UI created. The site may use a different cookie or a non-cookie storage key, or the state may be scoped differently than expected. Inspect a known accepted or rejected state in DevTools and compare it with the test session.
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.
The click times out
Verify the selector against the current page and check whether the banner appeared at all. A stored choice from an earlier run can suppress it. If the banner is present but the control is not clickable, inspect whether another overlay covers it or whether the page needs more time to render the control.
The banner is gone but the page still looks dimmed
Look for a separate backdrop or overlay element. Hiding only the banner can leave that element behind; inspect the page and handle the specific overlay for a visual-only capture. Also check scroll behavior and focus state rather than assuming the page is fully restored.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The screenshot captures the banner before dismissal
Take the screenshot only after the relevant wait condition confirms the banner is invisible or the intended page state is visible. Avoid relying solely on a fixed pause: page timing varies, and elapsed time does not prove the UI transition completed.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If you need a screenshot rather than a Selenium interaction test, ScreenshotNeo is a website screenshot API and MCP server. It can accept cookie and consent banners like a visitor and remove 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 cost nothing, and responses indicate the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
One GET request returns an image or PDF. This cURL example saves a WebP screenshot of the same example target:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/page -o shot.webp
See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo and start with 1,000 free screenshots a month, no card required.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteRank #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
Which approach should you use?
Use a real consent click when the test is about consent behavior. Initialize a state only after observing how the target site represents the choice, and use that when a repeatable state is more important than replaying the UI. Hide or remove the rendered banner only when the deliverable is a visual artifact and you have checked for leftover page effects. If Selenium itself is unnecessary, the ScreenshotNeo one-call capture above avoids setting up a browser session.
Frequently Asked Questions
Can Selenium remove a cookie banner without accepting cookies?
Yes. For a visual-only screenshot, you can hide or remove the rendered banner, but that does not record a consent decision and may leave other UI effects behind.
Can I use the same consent cookie for every website?
No. Consent names, values, and storage mechanisms are site-specific; inspect the target site after making a known choice.
Quick 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.
Does deleting cookies prove the banner-removal test works?
No. Deleting cookies can restore a first-visit state, but it does not test that the banner can be dismissed or that a consent choice persists.
Recommended Free Tools
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.

