selenium - WebDriver.findElement causing SocketExceptions for 10 seconds -


i having strange issue suite of webdriver test cases causing widespread failures.

one of test cases in suite expected fail - there open bug in web site causing tab disappear. test case supposed click tab calls webdriver's findelement method tab. waits standard timeout, then, instead of throwing usual exception , moving on, start getting socketexceptions in console aren't getting caught test case code catches errors:

apr 18, 2013 8:47:23 org.apache.http.impl.client.defaultrequestdirector tryconnect info: i/o exception (java.net.socketexception) caught when connecting target host: no buffer space available (maximum connections reached?): connect apr 18, 2013 8:47:23 org.apache.http.impl.client.defaultrequestdirector tryconnect  info: retrying connect  apr 18, 2013 8:47:23 org.apache.http.impl.client.defaultrequestdirector tryconnect  info: i/o exception (java.net.socketexception) caught when connecting target host: no buffer space available (maximum connections reached?): connect  apr 18, 2013 8:47:23 org.apache.http.impl.client.defaultrequestdirector tryconnect  info: retrying connect  apr 18, 2013 8:47:23 org.apache.http.impl.client.defaultrequestdirector tryconnect  info: i/o exception (java.net.socketexception) caught when connecting target host: no buffer space available (maximum connections reached?): connect  apr 18, 2013 8:47:23 org.apache.http.impl.client.defaultrequestdirector tryconnect  info: retrying connect 

the socketexceptions cause unreachablebrowserexception:

org.openqa.selenium.remote.unreachablebrowserexception: error communicating remote browser. may have died. build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01' system info: os.name: 'windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_32' driver info: driver.version: remotewebdriver     @ org.openqa.selenium.remote.remotewebdriver.execute(remotewebdriver.java:493)     @ org.openqa.selenium.remote.remotewebdriver.execute(remotewebdriver.java:502)     @ org.openqa.selenium.remote.remotewebdriver.quit(remotewebdriver.java:372)     @ com.brainshark.uitests.common.testbase.afterclass(testbase.java:243)     @ sun.reflect.generatedmethodaccessor8.invoke(unknown source)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25)     @ java.lang.reflect.method.invoke(method.java:597)     @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:45)     @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:15)     @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:42)     @ org.junit.internal.runners.statements.runafters.evaluate(runafters.java:36)     @ org.junit.runners.parentrunner.run(parentrunner.java:300)     @ com.brainshark.uitests.runners.brainsharktestrunner.run(brainsharktestrunner.java:51)     @ org.junit.runners.suite.runchild(suite.java:128)     @ org.junit.runners.suite.runchild(suite.java:24)     @ org.junit.runners.parentrunner$3.run(parentrunner.java:231)     @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:60)     @ org.junit.runners.parentrunner.runchildren(parentrunner.java:229)     @ org.junit.runners.parentrunner.access$000(parentrunner.java:50)     @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:222)     @ org.junit.runners.parentrunner.run(parentrunner.java:300)     @ org.apache.maven.surefire.junit4.junit4provider.execute(junit4provider.java:252)     @ org.apache.maven.surefire.junit4.junit4provider.executetestset(junit4provider.java:141)     @ org.apache.maven.surefire.junit4.junit4provider.invoke(junit4provider.java:112)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25)     @ java.lang.reflect.method.invoke(method.java:597)     @ org.apache.maven.surefire.util.reflectionutils.invokemethodwitharray(reflectionutils.java:189)     @ org.apache.maven.surefire.booter.providerfactory$providerproxy.invoke(providerfactory.java:165)     @ org.apache.maven.surefire.booter.providerfactory.invokeprovider(providerfactory.java:85)     @ org.apache.maven.surefire.booter.forkedbooter.runsuitesinprocess(forkedbooter.java:115)     @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:75) caused by: java.net.socketexception: no buffer space available (maximum connections reached?): connect     @ java.net.plainsocketimpl.socketconnect(native method)     @ java.net.plainsocketimpl.doconnect(plainsocketimpl.java:351)     @ java.net.plainsocketimpl.connecttoaddress(plainsocketimpl.java:213)     @ java.net.plainsocketimpl.connect(plainsocketimpl.java:200)     @ java.net.sockssocketimpl.connect(sockssocketimpl.java:366)     @ java.net.socket.connect(socket.java:529)     @ org.apache.http.conn.scheme.plainsocketfactory.connectsocket(plainsocketfactory.java:123)     @ org.apache.http.impl.conn.defaultclientconnectionoperator.openconnection(defaultclientconnectionoperator.java:148)     @ org.apache.http.impl.conn.abstractpoolentry.open(abstractpoolentry.java:149)     @ org.apache.http.impl.conn.abstractpooledconnadapter.open(abstractpooledconnadapter.java:121)     @ org.apache.http.impl.client.defaultrequestdirector.tryconnect(defaultrequestdirector.java:573)     @ org.apache.http.impl.client.defaultrequestdirector.execute(defaultrequestdirector.java:425)     @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:820)     @ org.openqa.selenium.remote.httpcommandexecutor.fallbackexecute(httpcommandexecutor.java:319)     @ org.openqa.selenium.remote.httpcommandexecutor.execute(httpcommandexecutor.java:297)     @ org.openqa.selenium.firefox.internal.newprofileextensionconnection.execute(newprofileextensionconnection.java:136)     @ org.openqa.selenium.firefox.firefoxdriver$lazycommandexecutor.execute(firefoxdriver.java:357)     @ org.openqa.selenium.remote.remotewebdriver.execute(remotewebdriver.java:472)     ... 32 more 

this causes each test case fail fast, , approximately 10 seconds, every attempt run next test case triggers above failure. then, magical happens, , exceptions cease.

does know why i'm seeing behavior? or takes 10 seconds reset? should work around trying detect situations , hold still 10 seconds before attempting execute next test case? thanks!

i figured out. socketexceptions being caused making many findelement calls in short period of time.

i have customized find method allows matching additional parameters text pattern in addition locator. under circumstances (namely, if there elements match locator not text pattern, such in case there multiple tabs, 1 text looking missing) method can make repeated findelement calls duration of timeout.

i never noticed issue in development because use 20 second timeout when i'm writing tests, fail faster. in our actual runs, use 180 second timeout, enough time overload selenium findelement calls.

i added sleeps ensure calling findelement every quarter of second @ most, , put in try/catch trap unreachablebrowserexception result if overload still occurs. if does, sleep 40 seconds , try again. seems working now.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -