DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

How to Take a Selenium Screenshot After Dismissing a Cookie Banner

A reliable Selenium screenshot flow: use the site's real consent control, wait for dismissal, and capture only after confirming the page state.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Navigate to the page, wait for its actual consent button to become clickable, select the intended consent option, then wait until the banner is no longer visible before saving the screenshot. Cookie banners have no universal selector or consent behavior, so replace the example locators below with ones that match the site you are testing.

Dismiss the banner, verify it is gone, then capture

This Python example uses Selenium explicit waits rather than an arbitrary sleep. The CSS selectors are illustrative only: inspect the target page and choose its real consent control and banner locator.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

# Illustrative selectors only; replace them for the target site.
consent_button = (By.CSS_SELECTOR, "button[data-testid='cookie-accept']")
banner = (By.CSS_SELECTOR, "[role='dialog']")

with webdriver.Chrome() as driver:
    driver.get("https://example.com")
    wait = WebDriverWait(driver, 10)

    wait.until(EC.element_to_be_clickable(consent_button)).click()
    wait.until(EC.invisibility_of_element_located(banner))

    saved = driver.save_screenshot("page.png")
    if not saved:
        raise OSError("Could not save screenshot")

Choose the site’s intended action—such as accepting, rejecting, or configuring consent—rather than assuming “accept” is always appropriate. After clicking, the example waits for the banner to become invisible. If the page has a more reliable success condition, such as a particular overlay disappearing or a consent state appearing, wait for that condition instead.

When the banner is inside an iframe

Switch into the relevant iframe before locating the consent control, then switch back to the default content before taking the screenshot if the page structure requires it. The frame and selector are site-specific; Selenium cannot infer them automatically.

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

Choose the screenshot output that fits the next step

driver.save_screenshot("page.png") writes a PNG of the current window and returns a boolean: check it to detect an I/O failure. To process the image in memory, use driver.get_screenshot_as_png() for PNG bytes; use driver.get_screenshot_as_base64() when you need a base64 representation. These ordinary methods capture the current window, not necessarily the full document.

As an Amazon Associate I earn from qualifying purchases.

Click the banner or seed cookie state?

Approach Best suited to Important limitation
Click the visible consent control Testing the user-facing consent flow and capturing the page after the real interaction. The control, choice and verification condition depend on the site.
Set browser cookies directly A controlled test that intentionally seeds a known consent state. You need the relevant cookie details and valid domain context; setting a cookie does not guarantee the banner will disappear.

Selenium’s cookie methods operate in the current browser context, and the browser must first be on a domain for which a cookie is valid. Treat direct cookie setup as test-state preparation, not as a universal replacement for the site’s consent workflow.

Full-page screenshots and browser scope

The standard current-window screenshot methods above should not be described as full-document capture. If the test requires the whole page, use a browser-specific full-document capability where supported; Selenium’s Firefox driver documentation lists full-document screenshot methods. Check the API for the browser and driver version in your environment before relying on that behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
CloudValley Webcam Cover for Logitech C920x / C920 / C922x / C922 / C930e | C920x HD Pro Web Cam Compatible, Camera Cover Protects Lens & Security, Protect Your Visual Privacy, Black
  • Privacy Protection and Lens Care: Avoid private information from hacking while preventing dust-fall and scratching of the camera lens
  • Multiple Compatibility: Suitable for Logitech webcam C920x, C920, C922, C930e, C922x Pro Stream HD Camera
  • Artful Design: Modeled and designed exclusively to fit the above devices from Logitech and make it more stylish
  • Easy Flip Mechanism: Can be turned 180 angle and easily take the cover off when flipping more than 180
  • Simple Installation: Attaches securely to your Logitech webcam without leaving residue, allowing for quick and hassle-free setup

Troubleshooting

  • Timeout waiting for the button: verify the selector against the live DOM, confirm the page finished rendering, and check whether the control is inside an iframe.
  • Click is intercepted or fails: the banner may still be animating, another overlay may cover the button, or the target may not be the actionable element. Wait for the actual control to be clickable and inspect the page state rather than adding a blind delay.
  • Click succeeds but the banner remains: check that you selected the intended consent action and that the post-click condition matches how the site dismisses the UI. Some sites hide, remove, or replace elements.
  • Screenshot is missing or false: check the output path and permissions; save_screenshot() returns false on an I/O error.
  • Screenshot includes the banner despite the click: ensure the dismissal wait completes before capture. If the banner is in a frame, verify that the frame interaction changed the page state you expect.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot without building and maintaining the Selenium flow, ScreenshotNeo provides a website screenshot API and MCP server. Its one-request API can return PNG, JPEG, WebP or PDF. For example, the cURL request below saves a WebP screenshot; see the ScreenshotNeo API documentation for options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners before capture 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 response headers identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up for 1,000 free screenshots a month, with no card required.

Quick Recap

Bestseller No. 2
Logitech C920S HD Pro Webcam Full 1080p/30fps Video Calling Clear Stereo
Logitech C920S HD Pro Webcam Full 1080p/30fps Video Calling Clear Stereo
Full HD 1080P video calls – premium video quality that makes you look like a Pro; HD autofocus and light Correction – enjoy razor-sharp high Def in every environment
$69.99
Bestseller No. 4
Viecam Webcam Privacy Shutter (Lens Cap, Hood Cover) Compatible with Logitech Webcams: Fits C920, C920x, C922, C922x, C930e, 1080P Pro Stream
Viecam Webcam Privacy Shutter (Lens Cap, Hood Cover) Compatible with Logitech Webcams: Fits C920, C920x, C922, C922x, C930e, 1080P Pro Stream
Protect the Webcam Clean from dust; Protect your privacy when you need to; Package includes: 1 X Black Viecam Webcam Privacy Shutter
$5.99
Bestseller No. 5
HUYUN The Webcam Privacy Shutter Protects Lens Cap Hood Cover Compatible for Logit HD Pro Webcam C920 & C930e & C922X C922x Pro
HUYUN The Webcam Privacy Shutter Protects Lens Cap Hood Cover Compatible for Logit HD Pro Webcam C920 & C930e & C922X C922x Pro
【Protecting the Camera】Protect the Webcam Clean,Farewell the dust; 【Package contents】 1 X Webcam Protects Lens Cap Hood Cover(Webcam not Included)
$6.99
Best Value
HUYUN The Webcam Privacy Shutter Protects Lens Cap Hood Cover Compatible for Logit HD Pro Webcam C920 & C930e & C922X C922x Pro
  • 【Multiple Compatibility】Compatible For Logit HD Pro Webcam C920 C930e and C922 C922x Pro
  • 【Protects Privacy】This webcam cover conveniently blocks your camera cover to protect your privacy
  • 【Protecting the Camera】Protect the Webcam Clean,Farewell the dust
  • 【Note】This item don't Compatible for Logit HD Pro Webcam C910 and B910 and other Webcam
  • 【Package contents】 1 X Webcam Protects Lens Cap Hood Cover(Webcam not Included)
Rank #4
Viecam Webcam Privacy Shutter (Lens Cap, Hood Cover) Compatible with Logitech Webcams: Fits C920, C920x, C922, C922x, C930e, 1080P Pro Stream
  • Compatible with the following models of Logitech webcam: C920, C920X, C920S, C922, C922X, C930e, Logitech 1080p Pro Stream Webcam
  • Protect the Webcam Clean from dust
  • Protect your privacy when you need to
  • Package includes: 1 X Black Viecam Webcam Privacy Shutter
  • Note: Webcam is NOT included
Rank #3
CloudValley Laptop Camera Cover Slide, Metal 0.023 Inch Ultra-Thin, 2 Packs
  • Privacy Protection: CloudValley webcam cover is designed for those who prioritize privacy, security, and peace of mind when using laptops, tablets, and computers
  • Fashion Design: The space aluminum alloy webcam cover features a subtle design which compliments the beautiful aesthetic of top devices
  • Ultra-Thin Design: Measures only 0.023 (0.6 mm) inch thin, ensuring it does not interfere with closing your laptop or device while providing reliable camera coverage
  • Broad Compatibility: Works flawlessly with most laptops (MacBook, HP, Dell, Asus, Acer, Lenovo), All-in-One PCs and leading tablets including iPad, Surface Pro, Galaxy Tab, Fire HD, and Google Pixel Tablet
  • Simple to Use: Only need to align to the webcam, attach and press it firmly for 15 seconds. Does not interfere with web use or indicator light
Rank #2
Logitech C920S HD Pro Webcam Full 1080p/30fps Video Calling Clear Stereo
  • Webcam comes with privacy shutter – puts you in control of what you show and protects the lens with a snugly fitting cover. Does not include the 3-month XSplit VCam license.
  • Full HD 1080P video calls – premium video quality that makes you look like a Pro
  • Full HD 1080P video Recording – a glass lens and full HD mean your recorded videos are crisp and vibrantly colored
  • HD autofocus and light Correction – enjoy razor-sharp high Def in every environment
  • Stereo audio with dual mics – capture natural sound on calls and recorded videos

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.

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

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.