Selenium is designed to kill Geckodriver process when disposing of the webdriver instance like this: driver.quit()
. In my testing framework, I have configured to call driver.quit()
after each test.
In some cases however, the test terminates abnormally due to various reason and then the finalizing steps (like quitting the driver) are not being executed. As a result I end up with multiple geckodriver processes that I can only kill manually.
Is there any good practice how to work around this problem? Perhaps monitoring the processes somehow and killing the ones that do not transfer any data?
Or maybe creating few instances and then reusing them?
I am running my tests on Grid so manipulating the process through command line won't work as it will only affect the grid hub.
EDIT:
There is an option of using taskkill
to terminate all the geckodriver processes on a machine but this is not a good solution since:
- I am running my tests through Selenium Grid so this will only affect the grid hub and not the nodes.
- There are multiple tests that run simultaneously and if I use
taskkill
I will kill the ones that are still in use as well. - I don't think that killing the processes using
taskkill
is a generally a good practice I would like to find a more elegant solution. E.g. (1)geckodriver processes are monitored on the node and only terminated locally when they are not in use or (2)somehow reused.