我正在运行测试: 硒3.11 Geckodriver v0.20.1 TestNG 6.9.8 Linux OS上的Firefox 57
我有10个套房,每个套房有10-30个班级。总持续时间约为16小时。 Webdriver在beforeClass中创建,并在afterClass中退出(使用driver.quit())。
当我使用Chrome驱动程序运行测试时,一切正常,所有套件都完全执行。
但是如果我将驱动程序切换到Firefox驱动程序,则只执行3-4或5个套件,然后我收到以下错误:
Cannot contact : java.nio.channels.ClosedByInterruptException
Can't take a screenshot: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14191
它出现在不同的步骤和操作中,测试只是定期进行 出现此错误:
2018-05-30 18:52:12.545 - NavigationTree.executeNavigationCommand:87 [[treePasteItem]]
2018-05-30 18:52:15.018 - Toastr.waitToastIsNotShown:51
2018-05-30 18:52:17.130 - NavigationTree.getRootNode:131
Cannot contact : java.nio.channels.ClosedByInterruptException
Can't take a screenshot: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14191
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'ip-172-31-34-46.ec2.internal', ip: '172.31.34.46', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.el7.x86_64', java.version: '1.8.0_45'
Driver info: driver.version: RemoteWebDriver
2018-05-30 18:53:16.441 - FAILED: RenameDeleteJobs_14
2018-05-30 18:53:16.441 - [LAST MESSAGE RECEIVED FROM THE TEST]
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14191
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'ip-172-31-34-46.ec2.internal', ip: '172.31.34.46', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.el7.x86_64', java.version: '1.8.0_45'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:611)
at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:638)
at org.openqa.selenium.interactions.Actions.perform(Actions.java:594)
at org.openqa.selenium.interactions.Actions$perform$0.call(Unknown Source)
at exa.tags.framework.utils.Helper.moveFocusToElement(Helper.groovy:290)
at exa.tags.framework.utils.Helper$moveFocusToElement$13.callStatic(Unknown Source)
at exa.tags.framework.utils.Helper.moveFocusToElement(Helper.groovy:298)
at exa.tags.framework.utils.Helper$moveFocusToElement$12.call(Unknown Source)
at exa.tags.framework.pages.navigation.NavigationTree.getNodeByName(NavigationTree.groovy:185)
at exa.tags.framework.pages.navigation.NavigationTree$getNodeByName$4.callStatic(Unknown Source)
at exa.tags.framework.pages.navigation.NavigationTree.getNodeByPath(NavigationTree.groovy:204)
at exa.tags.framework.pages.navigation.NavigationTree$getNodeByPath$9.callStatic(Unknown Source)
at exa.tags.framework.pages.navigation.NavigationTree.getNodeByPath(NavigationTree.groovy:223)
at exa.tags.framework.pages.navigation.NavigationTree.selectNodeByPath(NavigationTree.groovy:232)
at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:190)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at exa.tags.suites.jobs.RenameDeleteJobsTest.RenameDeleteJobs_14(RenameDeleteJobsTest.groovy:756)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1191)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.run(TestNG.java:1024)
at org.testng.TestNG$run$1.call(Unknown Source)
at exa.tags.runner.TestManager$_runTests_closure1$_closure4.doCall(TestManager.groovy:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at groovy.lang.Closure.call(Closure.java:426)
at groovy.lang.Closure.call(Closure.java:442)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at exa.tags.runner.TestManager$_runTests_closure1.doCall(TestManager.groovy:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at groovy.lang.Closure.call(Closure.java:426)
at groovy.lang.Closure.call(Closure.java:442)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at exa.tags.runner.TestManager.runTests(TestManager.groovy:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
at exa.tags.runner.TestManager.main(TestManager.groovy:38)
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14191
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:101)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:155)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
... 96 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at okhttp3.internal.platform.Platform.connectSocket(Platform.java:125)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)
... 116 more
我添加了内存信息输出,但似乎还有足够的资源用于JVM:
OS: Linux
Version: 3.10.0-514.el7.x86_64 amd64
Available processors (cores): 8
Current directory: /var/lib/jenkins/jobs/ExaCLOUD_UI_tests_pipeline/branches/feature-E.6pdikdaolhhr.IE-Chrome/workspace/ExaTAGS/TagsRunner
Currently allocated to the JVM: 2,249.5 Mb
Free memory in JVM: 1,257.568 Mb
Used memory in JVM: 991.932 Mb
Max memory the JVM could reach: 3,250 Mb
Total free memory: 2,258.068 Mb
File system root: /
Total space: 102387.98046875 Mb
Free space:30855.1953125 Mb
Usable space: 30855.1953125 Mb
我的问题是:在哪里查找以及添加什么来调试信息以调查发生这种情况的原因?
答案 0 :(得分:1)
此错误消息......
Cannot contact : java.nio.channels.ClosedByInterruptException
Can't take a screenshot: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:14191
...意味着当一个线程在另一个线程在通道上的I / O操作中被阻塞时中断它时,接收到已检查的异常。
ClosedByInterruptException
是一个已检查的异常,当一个线程在一个通道上的I / O操作中忙/阻塞时中断另一个线程时引发该异常。在抛出此异常之前,通道必须已关闭。
值得一提的是,通道操作几乎与执行I / O操作的线程绑定。如果此线程中断,则由于IO安全问题,流或通道将关闭。
您的代码试验会给我们提供更多关于出错的提示但是从错误堆栈跟踪中可以明显看出,主要问题之一是版本之间的不兼容您正在使用的二进制文件如下:
Test
。driver.quit()
方法中调用tearDown(){}
以关闭&正常销毁 WebDriver 和 Web客户端实例。如果 AUT(正在测试的应用程序)是一个多线程应用程序,您应该查找可能会中断在该通道上执行IO操作的线程的interrupt()
调用。如果它是一个Web应用程序或其他类型的托管环境,其中线程管理不适用于您的应用程序(如Servlet / EJB容器),您应该查找线程安全违规。另一个需要关注的地方是应用程序关闭或使用线程池时(Servlet / EJB容器!)。然后要注意池大小的动态管理!
您可以在Why are we getting ClosedByInterruptException from FileChannel.map in Java 1.6?
中找到详细的讨论