I keep getting an error like this
org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{localhost:13080, proxy=DIRECT hostAddress=localhost/127.0.0.1:13080 cipherSuite=none protocol=http/1.1}
when trying to read cookies from firefox. The exact same action can be performed with chrome with no problem. Port used is pretty random, anytime I start a new test I get a new port assigned as well. Should specifying another port be able to do something here? The line of code that produces it is:
driver.manage().getCookies().forEach(cookie -> System.out.println(cookie.toString()));
I wonder if it's an initialization problem with firefox and setting some value will get me past it. The initialization I do is just this:
FirefoxOptions Foptions = new FirefoxOptions();
Foptions.setBinary("/home/user/firefox/firefox");
Foptions.setCapability("marionette", true);
driver = new FirefoxDriver(Foptions);
It is tough to analyze the error without the error stack trace. The error stack trace would have helped immencely to debug the issue.
However this error message...
org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{localhost:13080, proxy=DIRECT hostAddress=localhost/127.0.0.1:13080 cipherSuite=none protocol=http/1.1}
...implies that the java.io.IOException was raised when you tried to invoke getCookies()
.
Your main issue can be one of the following:
driver.manage().getCookies()
though apparently it seems the HTML DOM have loaded but still some javaScript / Ajax Calls are active setting the cookies. Solution : Induce WebDriverWait for an element to be clickable as follows:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#btn_download"))).click()
Reason B : As per java.io.IOException: unexpected end of stream on Connection in android it may be possible that the server throwed an error and shut down as the parsing of the request was in progress.
在硒3.12.0及更高版本上使用driver.manage()。getCookies()方法时,我遇到了同样的问题,将硒版本降级为3.11.0,并且工作正常,此问题已在最新版本中引入。
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.