WebDriver:executeScript()导致BindException [英] WebDriver: executeScript() causes BindException

查看:81
本文介绍了WebDriver:executeScript()导致BindException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javascripthere 是在 Javascript:如何获取文本节点后面/前面的break标签并用ddb标签包装它们?

在通过WebDriver加载的每个页面上运行((JavascriptExecutor)驱动程序).executeScript(javascripthere)时,

while running ((JavascriptExecutor)driver).executeScript(javascripthere) on each page loaded via WebDriver,

测试运行3分钟后出现以下错误:

I get the following error after the test runs for 3 minutes:

Exception in thread "main" org.openqa.selenium.WebDriverException:
java.net.BindException: Address already in use: connect
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_18'
Driver info: driver.version: remote
        at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:
341)
        at
org.openqa.selenium.firefox.FirefoxDriver.execute(FirefoxDriver.java:
234)
        at
org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:
173)
        at
org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java:
231)
        at org.openqa.selenium.By$6.findElements(By.java:200)
        at
org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:
158)

Caused by: java.net.BindException: Address already in use: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(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:
133)
        at
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:
149)
        at
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:
108)
        at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:
415)
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
641)
        at
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:
211)
        at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:
125)
        at org.openqa.selenium.firefox.FirefoxDriver
$LazyCommandExecutor.execute(FirefoxDriver.java:341)
        at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:
328)
        ... 11 more 

基本上,这是为了捕获 text() xpath语法无法选择的文本节点。 Javascript使用< ddb> 标记将break标记之前和之后的文本节点包装起来。然后,WebDriver能够使用 / ddb 作为xpath语法来获取文本。

Basically the purpose of this is to capture the text nodes which cannot be selected by the text() xpath syntax. The Javascript wraps the text nodes before and after break tags with <ddb> tag. Then, WebDriver is able to get the text by using /ddb as xpath syntax.

事情似乎运行顺利但是在3分钟后崩溃并出现BindException错误。似乎我上一个问题中的Javascript引起了太多的出站连接。

Things seemingly run smoothly but crashes with the BindException error after exactly 3 minutes. It seems that the Javascript in my previous question is causing too many outbound connections.

我需要一个解决方案来允许Javascript在WebDriver中不断编辑DOM,以便文本节点是可以通过FirefoxDriver选择。

I need a solution to allow Javascript to continually edit the DOM in WebDriver so that text nodes is selectable by FirefoxDriver.

推荐答案

这是一个似乎已经被最近的变化(2010年10月28日)清除的问题。这是一个问题,即客户与selenium服务器交谈,甚至客户端与本地或远程的Firefox通信,都会耗尽短暂的端口数量。您应该将您的框架(客户端和服务器端,如果适用)更新为最新版本(alpha-7)。如果您无法升级,可以在本地增加临时端口的数量。对于Windows,修复程序是此处,否则,请进行一些Google搜索。

This was a problem that seems to have been cleared up by recent changes (28 Oct 2010). It was an issue with over-exhausting the amount of ephemeral ports by either the client talking to the selenium server or even the client talking to Firefox, locally or remotely. You should update your framework (client and server side, if applicable) to the newest release (alpha-7). If you're not in a position to upgrade, you can simply increase the number of ephemeral ports locally. For Windows, the fix is here, otherwise, do some googling.

问题: http://code.google .com / p / selenium / issues / detail?id = 923

修复: http://code.google.com/p/selenium/source/detail?r=10082

这篇关于WebDriver:executeScript()导致BindException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆