Skip to main content

Feb 13, 2019 - 2 minute read - Quora WebDriver Test Automation

When getting rid of a browser, what are the advantages of using taskkill.exe over close method in Selenium? Quora

Q: When getting rid of a browser, what are the advantages of using taskkill.exe over close method in Selenium?

A:

I can’t really think of any advantages to using taskkill.exe over a close or quit method in Selenium.

If the browser was opened by Selenium then I would try to have Selenium close it.

If the browser is unresponsive after executing selenium code then it may suggest a problem with the application under test making the browser unresponsive, which would imply issues with the application that need to be investigated.

Other issue might be cause by potentially a mismatch between the driver version and the browser version, so the environment used to execute the code from may need to be investigated.

TaskKill.exe would make your selenium code dependent on a Windows environment and would likely prevent your running your selenium execution through a local grid or a cloud grid.

If I was working on a project and saw that the code was using TaskKill.exe to close browsers I would be investigating:

  • what happens if you just use close or quit - i.e. is it really necessary?
  • why people think this is necessary? to explain some of the risks and issues I mention above
  • if it is necessary because quit or close do not terminate the browser session, then what changes to we have to make to our application or environment so that it is not necessary.

You should not really have to use taskkill.exe to close Selenium WebDriver initiated sessions.

Taskkill, or any process termination command, may be necessary if you using it as a temporary workaround because you are experiencing any of the issues I mentioned above. But it should really only exist as a temporary measure until you solve the problem that is causing the close or quit command to not terminate the browser.

Read this on Quora

- in Quora WebDriver Test Automation


You will need a Github account to comment. Or you can contact me with your comment.

I reserve the right to delete spam comments e.g. if your comment adds no value and its purpose is simply to create a backlink to another site offering training, or courses, or etc.