I've been trying to find a method to download files from websites within Selenium and found a solution here
Trouble is when I copy this example and stick it into eclipse I get an error on one line reading: -
Type mismatch: cannot convert from element type Object to Cookie
The section in question is: -
private BasicCookieStore mimicCookieState(Set seleniumCookieSet) {
BasicCookieStore mimicWebDriverCookieStore = new BasicCookieStore();
for (Cookie seleniumCookie : seleniumCookieSet) { <<---This is the problem line
BasicClientCookie duplicateCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue());
duplicateCookie.setDomain(seleniumCookie.getDomain());
duplicateCookie.setSecure(seleniumCookie.isSecure());
duplicateCookie.setExpiryDate(seleniumCookie.getExpiry());
duplicateCookie.setPath(seleniumCookie.getPath());
mimicWebDriverCookieStore.addCookie(duplicateCookie);
}
return mimicWebDriverCookieStore;
}
And is called from the section reading: -
LOG.info("Mimic WebDriver cookie state: " + this.mimicWebDriverCookieState);
if (this.mimicWebDriverCookieState) {
localContext.setAttribute(ClientContext.COOKIE_STORE, mimicCookieState(this.driver.manage().getCookies()));
}
I have no idea how to resolve this issue as I didn't write any of this code and am not that familiar, plus the original posting was well over a year ago so I'm guessing is no longer being monitored/updated.
Can anyone help me at all figuring this one out?
Any help much appreciated.
That is because you're using raw type Set
as parameter. Change it to Set<Cookie>
. For a raw type Set
, the iterator you get is just Iterator
. And it's next()
method will give you element of type Object
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments