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:

System.setProperty(“webdriver.chrome.driver”,”./exefiles/chromedriver.exe”);

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.
#ThanksForReading
#HappySelenium

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

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 to Amod Mahajan Cancel reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.
%d bloggers like this: