You can kill using below code: Runtime. getRuntime(). exec("taskkill /F /IM ChromeDriver.exe")
You can drop the chromedriver.exe in your virtual environment's bin/ directory.
per the Selenium API, you really should call browser.quit()
as this method will close all windows and kills the process. You should still use browser.quit()
.
However: At my workplace, we've noticed a huge problem when trying to execute chromedriver tests in the Java platform, where the chromedriver.exe actually still exists even after using browser.quit()
. To counter this, we created a batch file similar to this one below, that just forces closed the processes.
kill_chromedriver.bat
@echo off
rem just kills stray local chromedriver.exe instances.
rem useful if you are trying to clean your project, and your ide is complaining.
taskkill /im chromedriver.exe /f
Since chromedriver.exe is not a huge program and does not consume much memory, you shouldn't have to run this every time, but only when it presents a problem. For example when running Project->Clean in Eclipse.
browser.close()
will close only the current chrome window.
browser.quit()
should close all of the open windows, then exit webdriver.
Theoretically, calling browser.Quit will close all browser tabs and kill the process.
However, in my case I was not able to do that - since I running multiple tests in parallel, I didn't wanted to one test to close windows to others. Therefore, when my tests finish running, there are still many "chromedriver.exe" processes left running.
In order to overcome that, I wrote a simple cleanup code (C#):
Process[] chromeDriverProcesses = Process.GetProcessesByName("chromedriver");
foreach(var chromeDriverProcess in chromeDriverProcesses)
{
chromeDriverProcess.Kill();
}
//Calling close and then quit will kill the driver running process.
driver.close();
driver.quit();
I had success when using driver.close()
before driver.quit()
. I was previously only using driver.quit()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With