无法访问浏览器异常

无法访问浏览器异常

本文介绍了selenium 无法访问浏览器异常,java 套接字异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,尤其是在同一台电脑上运行多个任务和进程时,selenium webdriver 2 给出了许多无法访问的浏览器异常,这些异常总是带有 Java 套接字异常:

Recently, especially with multiple tasks and processes running on the same pc, selenium webdriver 2 is giving many unreachable browser exceptions which are always with a java socket exception:

 Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException:                         Could not start a new session. Possible causes are invalid address of the remote server or     browser start-up failure.
   Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
  System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.0',       java.version: '1.7.0_05'
   Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:493)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:182)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:185)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)

    Caused by: java.net.SocketException: Permission denied: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:150)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:575)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:319)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:297)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:136)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:357)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
... 7 more

为什么这种情况经常发生?selenim 2.25 与 firefox 14 不兼容吗?

Why does this happen so often? Is selenim 2.25 incompatible with firefox 14?

推荐答案

我发现自己在这个问题上挣扎了好几个月,我真的尝试了几乎所有的方法,但仍然出现随机的UnreachableBrowserException"错误.

I found myself struggling with this issue for months, i really tried almost everything but still got random "UnreachableBrowserException" errors.

这对我来说是唯一可行的解​​决方案.

This is the only working solution for me.

System.setProperty("java.net.preferIPv4Stack" , "true");

这篇关于selenium 无法访问浏览器异常,java 套接字异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 20:23