开发者

Selenium WebDriver Getting Error:java.net.SocketException: Connection reset

开发者 https://www.devze.com 2023-03-30 00:09 出处:网络
I am getting the following error Just to add this code was working fine earlier. I havent changed anything. The firefox browser open but nothing happens. I can see webdriver written in bottom right.

I am getting the following error

Just to add this code was working fine earlier. I havent changed anything. The firefox browser open but nothing happens. I can see webdriver written in bottom right.

Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
Build info: version: '2.4.0', revision: '13337', time: '2011-08-12 09:57:13'
System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.0', java.version: '1.7.0'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:404)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:106)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:89)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:78)
    at org.openqa.selenium.example.GetAllOptionInDropdown.main(GetAllOptionInDropdown.java:13)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:130)
    at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:127)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:233)
    at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:210)
    at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:271)
    at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:233)
    at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:209)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:292)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:126)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:483)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
    at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:274)
    at org.openqa.selenium.开发者_高级运维remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:254)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:125)
    at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:257)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:387)
    ... 5 more

Code Throwing Error:

   package org.openqa.selenium.example;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class GetAllOptionInDropdown  {
    public static void main(String[] args) {

        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.co.in/advanced_search");

        List<WebElement> element = driver.findElements(By.xpath("//div/table[2]/tbody/tr[3]/td/select/option"));
        System.out.println("Total DropDown Options "+ element.size());
        for (WebElement webElement : element) {
            System.out.println(webElement.getText());       
        }

        driver.quit();
    }
}


I made a same mistake by thinking that 2.9 was the latest version. After updating the version 2.25 from 2.9 my coding is working fine. :)


Try updating your gecko driver

I had the same problem using the chrome driver. It worked yesterday, today it didn't.

For reasons I don't understand, it worked after updating my chrome driver to the latest version. (2.25 instead of 2.9. Earlier I made the mistake of thinking 2.9 was the latest).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号