简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM