2013-03-28 48 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