Why And How Should We Terminate Browser Driver Executable File In Selenium WebDriver

Hello People,

Some days ago, I was running my regression automation suite and found webdriver is not able to launch browser. I was getting some socket exception. Whenever I face such situation, I just try to update browser version, browser driver version and selenium jar file version. Versioning non-compatibility is major issue in Selenium for not launching browser or URL.

When I downloaded “chromedriver.exe” and tried to replace with old one in folder. It was giving me exception that it can not be deleted as it is in use. But I was not running any scripts. I opened task manager and see there are so many instance which are up and running.

This is because we need to set a system property to launch any browser. Statement is as below:


Because of above statement, system launches new executable file for each program run keeping older executable files in memory. It can reduce your system performance drastically.

So, it is good idea to terminate the execution of executable files once you are done. Now we will see how can we do that. We need to use below statement to kill executable file:

Runtime.getRuntime().exec(“taskkill /F /IM chromedriver.exe”);

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.

10 thoughts on “Why And How Should We Terminate Browser Driver Executable File In Selenium WebDriver

  1. Excellent one
    Faced many times this issue as I was pasting the chromedriver executable in eclipse and each time I have to rename the driver existing in the folder and then paste my new executable chrome driver
    Later i used to delete the old renamed chrome driver
    Thanks for letting me know this would try using this

  2. Good Job Amod
    Ur knowledge is valuable to me …
    Thanks for sharing with us..
    Keep sharing such kind of tickey questions

  3. Such a great information and we are also facing the same..but we are killing all at once after executing one job through bamboo…we were searching how to do through script..we will apply and post again

      1. HI Amod, such great post ! In “KATALON STUDIO ” I want to kill IE driver after each execusion please help ..where I can use the code and what to use Thanks Regards, Mahesh Joshi

Leave a Reply

Your email address will not be published. Required fields are marked *