Selenium RemoteWebDriver 2.39 with firefox 26

时间:2014-01-07 06:28:37

标签: selenium-webdriver

我正在使用selenium-standalone-server-2.39作为RemoteWebDriver [服务器在不同的机器上运行]在Windows 7上运行firefox 26.测试执行正常但是当代码尝试关闭或退出驱动程序/套件拆解时,它会提供 UnreachableBrowserException。虽然如果我在本地使用webdriver [服务器在同一台机器上运行],它可以很好地工作。

我已经尝试使用不同版本的webdriver 2.36,2.37,2.38和ff 26 ,但每次都会出现相同的异常。

如果有人帮我解决了这个问题,那将会非常有帮助。

selenium webdriver和firefox的组合完美无缺?

编辑:我正在尝试运行这段简单的代码 -

 public static void main(String s[]) throws Exception {
       URL url = new URL( "http", ip, 4444, "/wd/hub" );
       FirefoxProfile pf = new FirefoxProfile(new File("D:\\ffprofile"));
       DesiredCapabilities capabilities =DesiredCapabilities.firefox();
       capabilities.setCapability(FirefoxDriver.PROFILE, pf);
       System.out.println("1");
       capabilities.setJavascriptEnabled(true);
       System.out.println("2");
       WebDriver driver = new RemoteWebDriver(url,capabilities);
      System.out.println("4");
      driver.get("http://www.google.com");
      driver.close();
    }

例外:

    Jan 07, 2014 1:10:32 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
    INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset
    Jan 07, 2014 1:10:32 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
    INFO: Retrying request
Jan 07, 2014 1:10:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset
Jan 07, 2014 1:10:51 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Jan 07, 2014 1:11:10 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset
Jan 07, 2014 1:11:10 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.38.0', revision: 'bd32d4e', time: '2013-12-05 16:15:38'
System info: host: 'symc-w7-12281', ip: '10.88.155.166', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
    at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:418)
    at SeleniumTest.main(SeleniumTest.java:30)
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:160)
    at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:84)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:273)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260)
    at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:283)
    at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:251)
    at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:223)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
    at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:682)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
    at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:319)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:298)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
    ... 3 more

2 个答案:

答案 0 :(得分:1)

尝试在代码中注释掉这一行:

capabilities.setCapability(FirefoxDriver.PROFILE, pf);

不要指定要在网格上使用的配置文件,只需显式配置网格配置中的配置文件,或者根本不指定配置文件,以便Firefox只使用默认配置文件。

如果您查看Selenium 2.41.0(https://selenium.googlecode.com/git/java/CHANGELOG)的发行说明,您会发现Firefox 26不再受支持。它在2.39中得到支持,但您可以使用发行说明来确保使用正确的版本。实际上,Selenium 2.44.0仅支持Firefox 24,31,32和33。

答案 1 :(得分:0)

我会尝试降级您的Firefox版本