Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

release Selenium chromedriver.exe from memory

People also ask

How do I remove ChromeDriver exe?

You can kill using below code: Runtime. getRuntime(). exec("taskkill /F /IM ChromeDriver.exe")

Where is ChromeDriver exe stored?

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().