Saturday, August 25, 2018

How do I kill the Chrome driver processor by using selenium

In this post, we are going to explain how to kill chrome driver background process or release chromedriver.exe from memory with help of selenium webdriver.
As per the Selenium API, you really should call browser.quit() as this method will close all windows and kills the process. However most of time, we have noticed a huge problem when trying to execute chromedriver tests in the Java platform, where the chromedriver.exe actually still exists. To overcome such problem you need to apply below command in commands prompt.

How do I kill the Chrome driver processor by using selenium

Kill Multiple Processes From the Command Line

The first thing you’ll need to do is open up a command prompt, and then use the taskkill command with the following syntax:
taskkill /F /IM <processname.exe> /T

These parameters will forcibly kill any process matching the name of the executable that you specify. For instance, to kill all iexplore.exe processes, we’d use:
taskkill /F /IM iexplore.exe

It will kill the chrome driver background process, once you have entered above commands in command prompt. Refer the below screenshot :
How do I kill the Chrome driver processor by using selenium

You can directly run above command with help of java coding :

Method -1 :
Process[] chromeDriverProcesses = Process.GetProcessesByName("chromedriver");
foreach(var chromeDriverProcess in chromeDriverProcesses){

Method -2 :
Runtime.getRuntime().exec("taskkill /F /IM chromedriver.exe /T");

This will help you to release chromedriver.exe background process from the memory. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.

No comments:

Post a Comment