如何运行InternetExplorerDriver Selenium测试后杀IEDriverServer.exe控制台窗口 [英] How to kill IEDriverServer.exe console window after running an InternetExplorerDriver Selenium test

查看:3066
本文介绍了如何运行InternetExplorerDriver Selenium测试后杀IEDriverServer.exe控制台窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Visual Studio的单元测试运行硒的webdriver并使用InternetExplorerDriver。这将激活IEDriverServer.exe在控制台窗口。

I'm running Selenium Webdriver through a Visual Studio Unit Test and using the InternetExplorerDriver. This fires up IEDriverServer.exe in a console window.

这伟大工程和测试执行。一旦测试执行完毕,我想杀了那个的cmd.exe窗口,以便它不是游逛为我所要做的手动清除。我有上千次的试验,所以你可以想像这个管理的烦恼。

This works great and the test executes. Once test execution finishes i'd like that cmd.exe window killed so that it's not hanging around for me to have to do manual cleanup. I have thousands of tests so you can imagine the headache of managing this.

有处理这种无需做后期的测试执行和Kill.exe与杀戮的cmd.exe进程等优雅的方式?我试着InternetExplorerDriverService.HideCommandPromptWindow =真,但只是运行在隐藏模式CMD.EXE并保留进程在运行,直到它的手动杀死。我也试着InternetExplorerDriverService.Sup pressInitialDiagnosticInformation和所有所做的是燮preSS一些写入cmd.exe窗口中的信息。

Is there an elegant way to handle this without having to do post test execution and killing cmd.exe processes with kill.exe, etc? I've tried InternetExplorerDriverService.HideCommandPromptWindow = true, but that just runs cmd.exe in hidden mode and leaves the process running until it's manually killed. I've also tried InternetExplorerDriverService.SuppressInitialDiagnosticInformation and all that does is suppress some of the information written to the cmd.exe window.

推荐答案

有两种方式:


  1. 所建议的意见 driver.quit()将做的工作。

但有时我们的测试失败,驱动程序继续运行。为避免驱动程序可以使用的多个实例:调用Runtime.getRuntime()EXEC(TASKKILL / T / F / IM IEDriverServer.exe);

But sometimes our test fails and the Driver keeps running. To avoid having multiple instances of drivers you can use: Runtime.getRuntime().exec("taskkill /T /F /IM IEDriverServer.exe");.

使用此命令的好处是,即使你的脚本不能完全运行它仍然会杀死司机。

The benefit of using this command is that even if your script doesn't run completely it would still kill the driver.

可以在许多地方使用它。例如:

You can use it in a number of places. For example:


  1. 如果您使用的是框架,例如TestNG的可以覆盖onTestFailure()。

  2. 您可以在您的测试的开头添加它,这样,如果有任何实例已经打开,他们会被杀死。

  3. 或者你也可以在其他地方,如catch块添加。

这篇关于如何运行InternetExplorerDriver Selenium测试后杀IEDriverServer.exe控制台窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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