WebDriver: executeScript() causes BindException
javascripthere
is the script found at Javascript: how to get text nodes following/preceding break tags and wrap them with ddb tag?
while running ((JavascriptExecutor)driver).executeScript(javascripthere)
on each page loaded via WebDriver,
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.NewPr开发者_StackOverflow中文版ofileExtensionConnection.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
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.
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.
I need a solution to allow Javascript to continually edit the DOM in WebDriver so that text nodes is selectable by FirefoxDriver.
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.
Issue: http://code.google.com/p/selenium/issues/detail?id=923
Fix: http://code.google.com/p/selenium/source/detail?r=10082
精彩评论