2013-03-28 40 views
4

请指导我如何终止IE驱动程序的实例。在我运行测试并完成之后,浏览器正在退出,因为我已经使用了driver.quit(),但发现在任务管理器中交叉检查时实例仍然存在。如何在webdriver中为IE服务器终止命令行服务器

骨架代码:

driver=new InternetExplorerDriver(); //calling IE driver 
testRun(); // run my test                       
driver.quit(); 

在此先感谢

+0

你试过driver.close( ); - http://selenium.googlecode.com/git/docs/api/java/index.html?org/openqa/selenium/WebDriver.html – aimbire 2013-03-28 11:58:03

+4

@aimbire'close()'方法绝对**不**保证关闭IEDriverServer.exe实例。 'quit()'方法是正确的方法。 – JimEvans 2013-03-29 12:11:42

回答

1

我已经为你的方法,

public void ieKiller() throws Exception 
{ 
    final String KILL = "taskkill /IM "; 
    String processName = "IEDriverServer.exe"; //IE process 
    Runtime.getRuntime().exec(KILL + processName); 
    Wait(3000); //Allow OS to kill the process 
} 

source