Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver: Delete Cookies On All Domains

In selenium you can only delete cookies on the current domain, but would it be possible to navigate to the file where Firefox is storing the cookies and either delete the file or overwrite it? I've been looking around, but can't find where selenium stores the cookies.

like image 630
J.Miller Avatar asked Apr 21 '13 02:04

J.Miller


People also ask

How do you clear all cookies in Selenium?

Navigate to the Chrome settings page with Selenium by executing the driver. get('chrome://settings/clearBrowserData') . Click on the Clear Data button to clear the cache.

Does Selenium clear cache?

Selenium does not provide a way to delete cache, here are some workarounds. There are a few ways in which cache can be deleted using Selenium Webdriver for regular Chrome browsers. For instance, here they explain how selenium can be used to clear cache like a real user i.e., by navigating to chrome settings.

Can Selenium manipulate cookies?

Selenium WebDriver provides multiple commands for handling the cookies in a website. These Selenium cookies APIs provide you the required mechanism for interacting and querying the cookies.


2 Answers

You can specify a user directory and then manipulate <userdir>/Default/Cookies. This question is similar: Getting or Manipulating all cookies in Selenium Webdriver

like image 147
Michael W Avatar answered Sep 23 '22 01:09

Michael W


Selenium doesn't store the cookies, the browser does. So the answer to "where [the browser] stores the cookies" will be different for each browser. But since Selenium always starts the browser with a clean profile, you shouldn't have to do this - there are no cookies when the browser starts.

like image 21
Ross Patterson Avatar answered Sep 23 '22 01:09

Ross Patterson