如何在网格上运行时关闭ChromeDriver? [英] How to close a ChromeDriver when running on Grid?

查看:167
本文介绍了如何在网格上运行时关闭ChromeDriver?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用带有Selenium Grid 2的RemoteWebDriver通过TestNG套件运行我的测试。这适用于Firefox和IE。现在我添加了Chrome并且测试运行正常,但是在套件的所有测试之后调用driver.quit()时总是会出现异常(适用于FF和IE)。

I am currently running my tests with RemoteWebDriver with Selenium Grid 2 through TestNG suites. This works fine with Firefox and IE. Now I added Chrome and the tests run fine, but I always get an Exception when calling driver.quit() after all tests of a suite (works fine for FF and IE).

Exception如下所示:

The Exception looks like this:

Error communicating with the remote browser. It may have died.
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)    
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:476)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:346)
at setups.StandardChromeSetup.tearDown(StandardChromeSetup.java:42)
19 lines not shown

Caused by Error communicating with the remote browser. It may have died. 
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:467)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:476)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:346)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
at $Proxy1.quit(Unknown Source)
at  org.openqa.selenium.support.events.EventFiringWebDriver.quit(EventFiringWebDriver.java:194)
at org.openqa.selenium.remote.server.handler.DeleteSession.call(DeleteSession.java:42)
at org.openqa.selenium.remote.server.handler.DeleteSession.call(DeleteSession.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:150)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722) 

我正在使用Selenium版本2.24.1和chromedriver.exe 21.0.1180.4

I am using Selenium Version 2.24.1 and chromedriver.exe 21.0.1180.4

编辑

tearDown代码:

Code for tearDown:

@AfterSuite
public void tearDown(){
  driver.quit();
}

使用RemoteDriver完美适用于FF和IE。但不适用于镀铬。

Works perfectly for FF and IE with RemoteDriver and without. But not for chrome.

推荐答案

遇到同样的问题。 此处是我解决问题的方法。这似乎是新版Chrome驱动程序的一个错误。使用以前版本的驱动程序(20.0.1133.0)为我解决了这个问题。

Faced the same problem. Here is how I resolved it. This seems to be a bug with the new version of the Chrome driver. Using the previous version of the driver (20.0.1133.0) solved this issue for me.

检查驱动程序下载页面

这篇关于如何在网格上运行时关闭ChromeDriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆