What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To handle cookies in Selenium WebDriver, first navigate to a page on the cookie’s domain, then use your language binding’s add, get, or delete cookie methods. In Python, for example, use driver.add_cookie() to add one, driver.get_cookies() to inspect all cookies, and driver.delete_cookie() or driver.delete_all_cookies() to remove them.
Why you must open the cookie’s domain first
WebDriver cookie commands apply to the current browsing context. Navigate to a page on the domain for which the cookie is valid before adding or inspecting it. Selenium’s guide states: “First of all, you need to be on the domain that the cookie will be valid for.” Selenium: Working with cookies
As an Amazon Associate I earn from qualifying purchases.
If the homepage is slow, Selenium notes that you can open a smaller page on the same site before adding the cookie. The important point is that the current page must be on the relevant domain.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Add, inspect, and delete cookies in Python
The following Python examples use the cookie methods shown in Selenium’s documentation. Check the API reference for the Selenium version and browser binding installed in your project; signatures and accepted fields can vary across language bindings.
#1 Best Overall
Add a cookie
After navigating to the relevant domain, pass a cookie dictionary to add_cookie():
driver.get("https://example.com/")
driver.add_cookie({"name": "key", "value": "value"})
The required example fields are the cookie’s name and value. Add attributes only when your test needs them and the binding accepts them.
Rank #2
Get one cookie or inspect all cookies
Use get_cookie() to retrieve a cookie by name, or get_cookies() to inspect the cookies available in the current context:
cookie = driver.get_cookie("foo")
cookies = driver.get_cookies()
Use the all-cookies method when you need to examine the current cookie set rather than look up a single known name.
Rank #3
Delete one cookie or clear the current set
Delete a named cookie with delete_cookie(). Use delete_all_cookies() only when the test intends to clear every cookie in the current context:
driver.delete_cookie("test1")
driver.delete_all_cookies()
Cookie attributes beyond name and value
Selenium’s documentation includes cookie fields and builder options such as path, secure, and sameSite. Its Python examples demonstrate sameSite values of Strict and Lax. Consult the reference for your language binding and version for the exact accepted keys and syntax.
Rank #4
For example, the documentation shows the attribute shape as a dictionary alongside the name and value:
driver.add_cookie({
"name": "key",
"value": "value",
"path": "/",
"secure": True,
"sameSite": "Lax"
})
Choose attributes to match the site and the test case; do not assume that every binding exposes identical method signatures or accepts identical cookie fields.
Best Value
Equivalent Java API placement
In Java, cookie operations are exposed through the driver’s management interface. Selenium’s examples include adding a cookie with a Cookie object and retrieving the set with getCookies():
driver.manage().addCookie(new Cookie("key", "value"));
Set<Cookie> cookies = driver.manage().getCookies();
As with Python, navigate to the relevant domain first and check the Java API reference for the Selenium version used by the project. Java WebDriver.Options API reference
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common cookie-handling problems
- Adding a cookie before navigating: First open a page on the cookie’s valid domain, then call the add method.
- Looking for a cookie that is not in the current context: Confirm the driver is on the relevant site, then inspect the set with the binding’s get-all method.
- Using attribute syntax from a different language: Follow the official example or API reference for the binding and version in your project; method placement and accepted fields differ.
- Clearing more than the test intended: Use the named-cookie delete method when removing one cookie. Reserve delete-all for tests that intentionally clear the entire current cookie set.
- Assuming an optional attribute is universally supported: Check the installed binding’s reference and the browser in use before relying on fields such as
sameSiteorsecure.
Or skip the browser setup
If your goal is a clean screenshot rather than exercising WebDriver cookie behavior, ScreenshotNeo can capture a page without setting up a browser script. Its API accepts a URL in one GET request; the examples below use https://stripe.com.
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 matchWindows 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 reinstallQuick Recap
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo API documentation for request details. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers indicating the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo free.
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.




