Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver get cookies full domain in internet explorer

I am trying to obtain the Cookies from the whole domain of a site but I can't seem to get it. Here is my code:

Set<Cookie> cookies = driver.manage().getCookies();

    for (Cookie cookie : cookies) {
        System.out.println(cookie);
    }

This does what I want, however, I have a cookie that has another path value, and this snippet is not returning the correct cookie, any ideas?

Note: This works flawlessly on Chrome and Firefox, the browser in question is IE.

like image 561
nland Avatar asked Sep 30 '22 15:09

nland


1 Answers

As far as my understanding and knowledge Internet explorer when opened with selenium maintain cookie and cache from earlier activities. At the time of initiating you can clean the instance.

capabilities = DesiredCapabilities.InternetExplorer();
capabilities.SetCapability("ie.ensureCleanSession", true);

ie.ensureCleanSession

When set to true, this capability clears the cache, cookies, history, and saved form data. When using this capability, be aware that this clears the cache for all running instances of Internet Explorer, including those started manually.

Please do tell me if this information is helpful

Thanks

like image 70
Gaurav Avatar answered Oct 02 '22 15:10

Gaurav