Over a million developers have joined DZone.

Any Advantages of Using taskkill.exe Over the Close Method in Selenium?

DZone 's Guide to

Any Advantages of Using taskkill.exe Over the Close Method in Selenium?

Learn more about one tester's thoughts on using taskkill.exe over the close method in Selenium.

· Performance Zone ·
Free Resource

Q: When getting rid of a browser, what are the advantages of using taskkill.exe over the 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.

Another issue might be caused potentially by 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 you from 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 do people think this is necessary? Then, I would explain some of the risks and issues I mentioned above
  • If it is necessary, because quit or close do not terminate the browser session, then what changes do 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.

This article was syndicated from blog.eviltester.com. Author Alan Richardson is an Agile Software Development and Testing Consultant he has written 4+ books including Dear Evil Tester, Automating and Testing a REST API, Java For Testers. He has created 6+ online training courses covering Technical Web Testing, Selenium WebDriver and other topics. He is a prolific content creator on his blog, Youtube and Patreon.

performance ,close ,selenium ,opinion ,taskkill.exe ,quit

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}