7

我有一个 java webdriver 驱动的 selenium 执行,它在列表上循环以将不同的信息输入到文本框中并使用 FirefoxDriver 发送它。

在一台计算机上,非常可重现,在第 10 次或第 11 次迭代之后, findElement(By.id("mi4"))调用UnreachableBrowserException.

Jun 29, 2012 1:52:02 PM org.apache.http.impl.client.DefaultRequestDirector tryConnect
Information: I/O exception (java.net.BindException) caught when connecting to the target host: Address already in use: connect
Jun 29, 2012 1:52:02 PM org.apache.http.impl.client.DefaultRequestDirector tryConnect
Information: Retrying connect
Jun 29, 2012 1:52:02 PM org.apache.http.impl.client.DefaultRequestDirector tryConnect
Information: I/O exception (java.net.BindException) caught when connecting to the target host: Address already in use: connect
...
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_04'
Driver info: driver.version: RemoteWebDriver
   at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:467)
   at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
Caused by: java.net.BindException: Address already in use: connect
   at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
   at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
   at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:337)
   at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:297)
   at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:136)

没有第三方程序监听任何端口。但是,我使用了 FirefoxDriver 的两个实例,这意味着两个 Firefox 实例/Windows 并行打开,这在 Win7 机器上运行没有任何问题,所描述的问题发生在 Windows XP 机器上。

我使用带有 selenium 2.24.1 的 Firefox 13。

4

1 回答 1

7

听起来您的临时端口用完了,因为您一遍又一遍地迭代。在 Windows XP 中,临时 TCP 端口的默认最大数量为 5000。尝试根据此处的 Microsoft 知识库文章中的解决方案增加限制。重新启动机器。这个解决方案对我有用。

于 2012-07-01T15:37:39.513 回答