vamsi chandra
vamsi chandra

Reputation: 61

Retrieving 3rd party and All Cookies using Selenium Webdriver Java

i want to retrieve all cookies names and domains from an URl using selenium webdriver xx.21 with java,

i am using this below code:

driver.navigate().to("http://www.nextag.com");
Set<Cookie> cookies = driver.manage().getCookies();
Iterator<Cookie> itr = cookies.iterator();

    while (itr.hasNext()){
    Cookie c = itr.next();
    System.out.println("Cookie Name: " + c.getName() + " --- " + "Cookie Domain: " + c.getDomain() + " --- " + "Cookie Value: " + c.getValue());
    }

From the above code i am getting only some but when i check manually there are some more cookies has to be dropped by advertisements, like (scorecardresearch.com) cookies which is expected, How to get all those by selenium code? Any answer would be really helpful. Thank you

Upvotes: 3

Views: 6480

Answers (1)

Vishnu
Vishnu

Reputation: 319

There is a workaround for this using a Mozilla firefox add-on which will save all cookies in XML format under current profile directory. This add-on will save cookies from all domains and can be accessed using webdriver.

For more details on implementation using C#, refer to following blog: http://automationoverflow.blogspot.in/2013/07/getting-cookies-from-all-domains.html

Upvotes: 2

Related Questions