Java 硒与;“无法访问的浏览器异常/地址已在使用中”;发生在一台计算机上

Java 硒与;“无法访问的浏览器异常/地址已在使用中”;发生在一台计算机上,java,firefox,selenium,webdriver,Java,Firefox,Selenium,Webdriver,我有一个java webdriver驱动的selenium执行,它在列表上循环,将不同的信息输入文本框,并使用FirefoxDriver发送 在一台计算机上,在第10次或第11次迭代后,调用findelelement(By.id(“mi4”))会引发无法访问的浏览器异常 Jun 29, 2012 1:52:02 PM org.apache.http.impl.client.DefaultRequestDirector tryConnect Information: I/O exception (

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

在一台计算机上,在第10次或第11次迭代后,调用
findelelement(By.id(“mi4”))
会引发
无法访问的浏览器异常

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机器上


我将Firefox 13与selenium 2.24.1配合使用。

由于您反复迭代,所以听起来您的临时端口似乎已经用完了。在windows XP中,临时TCP端口的默认最大数量为5000。尝试根据Microsoft KB文章中的分辨率增加限制。重新启动机器。这个解决方案对我有效。

谢谢,我试试这个。我猜这些端口是selenium在与浏览器通信时使用的?他们不会重复使用吗?我只有两个FirefoxDriver实例……在使用jenkins运行selenium测试用例时,我曾多次遇到过这个问题。从没想过这是问题的原因。回答得很好。@stracktracer Selenium使用JSONWireProtocol与浏览器通信,并使用TCP临时端口。很可能以前的浏览器没有正常退出,连接仍然打开。我有一个新启动的机器的问题。它不可能是短暂的端口,但我怀疑是chrome更新导致了一个bug。