nland
nland

Reputation: 669

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.

Upvotes: 5

Views: 2151

Answers (1)

Gaurav
Gaurav

Reputation: 83

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

Upvotes: 4

Related Questions