Multithreading 当我们使用线程本地概念并行运行Selenium并行运行测试用例时,测试用例会在中间失败,每次运行都会抛出diff错误

Multithreading 当我们使用线程本地概念并行运行Selenium并行运行测试用例时,测试用例会在中间失败,每次运行都会抛出diff错误,multithreading,selenium,parallel-processing,Multithreading,Selenium,Parallel Processing,当我使用线程本地概念并行运行时。它正在启动浏览器,测试用例正在并行运行,但突然之间它们失败了,浏览器正在关闭,就像@AfterMethod事件一样 如果有人帮助我,那将是很大的帮助 代码:- 错误:- un 16, 2017 4:25:52 PM org.openqa.selenium.support.ui.ExpectedConditions findElement WARNING: WebDriverException thrown by findElement(By.xpath: //i

当我使用线程本地概念并行运行时。它正在启动浏览器,测试用例正在并行运行,但突然之间它们失败了,浏览器正在关闭,就像@AfterMethod事件一样

如果有人帮助我,那将是很大的帮助

代码:-


错误:-

un 16, 2017 4:25:52 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.xpath: //img[@pc-id = 'logo-big'])
org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 43 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'TNAKKA21D0RG2', ip: '10.96.132.116', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: com.emergya.selenium.drivers.EmergyaChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41), userDataDir=C:\Users\tnakka\AppData\Local\Temp\scoped_dir8656_4015}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=59.0.3071.104, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: f5fdba75431a5c436e43acbb14e76291
*** Element info: {Using=xpath, value=//img[@pc-id = 'logo-big']}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  • 警告:findElement引发WebDriverException(by.xpath://img[@pc id='logo big']) org.openqa.selenium.webdrivexception:org.apache.http.conn.HttpHostConnectException:Connect to localhost:19258[localhost/127.0.0.1,localhost/0:0:0:0:0:1]失败:连接被拒绝:连接 生成信息:版本:“3.4.0”,版本:“未知”,时间:“未知” 系统信息:主机:'TNAKKA21D0RG2',ip:'10.96.132.116',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8.0_111' 驱动程序信息:Driver.version:emergyachromediver 位于org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)

  • 警告:findElement引发WebDriverException(by.xpath://img[@pc id='logo big']) org.openqa.selenium.remote.SessionNotFoundException:没有这样的会话 (驱动程序信息:chromedriver=2.28.455520(cc17746adff54984afff480136733114c6b3704b),平台=Windows NT 6.1.7601 SP1 x8664)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:2毫秒

  • java.lang.NullPointerException


  • 这通过下面的语句得到修复


    您必须确保绝对没有全局静态变量。当执行并行运行时,一切都必须是线程安全的(如浏览器实例)

    代码放置在以下位置:-