3

My program launches several dozen instances of WebDriver in parallel and kills them when certain conditions are met or when I manually terminate the program. At any given time I might have 4 dozen active WebDriver instances and to kill unwanted instances I call:

driver.quit();

If driver.quit(); throws exception I kill WebDriver by PID via Runtime.getRuntime().exec() taskkill command.

Most of the active drivers are destroyed with this call (when I exit program). However, there's usually a handful (1-3) that 'hang' with the message Mozilla FireFox (Not Responding). And they never die.

I'm unable to determine the root cause of the issue as the command I'm using to kill WebDriver is generally working. I've looked at several threads on SO regarding similar issues but I feel none of them address my problem because, as stated, the command I'm using works in general - it's just not working on all instances. As far as I see, there's is no difference between the way any of the drivers operate. Also, no error/exception is thrown when I call driver.quit(). So it seems purely random when the command works and doesn't work.

What might cause Firefox to hang like this and not respond to quit() command?

Thanks!

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Alan Cook
  • 342
  • 3
  • 14

1 Answers1

0

You are on the right track but when certain conditions are met don't manually terminate the program instead use:

driver.quit();

You can find a detailed discussion in PhantomJS web driver stays in memory


In case you need to kill the Firefox processes forcefully you can also use the taskkill() (windows) command through getRuntime().exec() as follows:

Runtime.getRuntime().exec("taskkill /F /IM firefox.exe /T");

You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?


In case Mozilla FireFox hangs with the message Mozilla FireFox (Not Responding) effectively means that something stopped Mozilla FireFox processes.


Solution

As per the article Firefox is not responding there are multiple approaches to solve this issue (Windows 10) as follows:

  • Close Mozilla FireFox (if the classic way isn’t working, close the program through Task Manager)
  • Restart your system.
  • Update the system graphics card drivers: Firefox can run into issues due to outdated drivers for the graphics card. You need to make sure that your system runs on the latest driver updates.
  • Disable hardware acceleration from Firefox: Hardware acceleration feature is also related to the graphics card. In some situations, depending on certain graphic card setups, Firefox might get into a freeze loop when hardware acceleration is in use. So, turn off this feature.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    thanks for your response however I am already calling driver.quit() (when I wrote about manually terminating program it's just a signal to call driver.quit() so you can ignore that part) My issue is that while the majority of instances are destroyed after calling driver.quit there's always 1 or 2 that 'hang'. Manually closing instance via task manager defeats the entire purpose of automation. It's also not practical for me to 'babysit' the server 24/7 as dozens of instances are launched and destroyed every hour. Looking forward to your insight. Thanks! – Alan Cook Nov 04 '19 at 16:28