Multithreading 当我们使用线程本地概念并行运行Selenium并行运行测试用例时,测试用例会在中间失败,每次运行都会抛出diff错误
当我使用线程本地概念并行运行时。它正在启动浏览器,测试用例正在并行运行,但突然之间它们失败了,浏览器正在关闭,就像@AfterMethod事件一样 如果有人帮助我,那将是很大的帮助 代码:-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
错误:-
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)
这通过下面的语句得到修复
您必须确保绝对没有全局静态变量。当执行并行运行时,一切都必须是线程安全的(如浏览器实例)代码放置在以下位置:-