Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - "Firefox is already running" error

We are running some tests using selenium. We have dedicated Windows XP VM's for that, with one selenium RC server on each VM, and no other process running on that VM. We open and close a selenium session for each test. The tests always call selenium.stop() when they finish. A lot of times (1 in 30 I would say) one test hangs, and when I view the desktop of the machine that has been allocated to it I see a popup with "Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system."

  • I am sure only one test communicates with a VM at a given time
  • All tests make sure to stop() the selenium when they're done.
  • we have very verbose logging, and the log shows that no test had any problems before the test that got the "firefox is already running" error.
  • The test that gets this error is arbitrary, since it happens right after calling selenium.start() and thus isn't caused by any specific code.
  • The teardown is the same for all tests

What could be causing this, and how can I prevent it?

like image 654
olamundo Avatar asked Oct 15 '22 11:10

olamundo


1 Answers

When Selenium runs your integration tests, it's literally starting up a new copy of Firefox for each test. If a test gets stuck and there's an existing copy of Firefox running with the same profile, it won't be able to start the next one. (That's a Firefox limitation, not a Selenium one.) You should make sure that:

  • your teardown method is closing the browser each time with Selenium.stop
  • you use timeouts and the WaitFor*() methods to limit the amount of a time a test can spend executing its instructions
  • you're using a separate profile for Selenium to run in (you should get this automagically if you haven't changed any settings) distinct from any other Firefox profiles that may already be on the machine
like image 175
John Feminella Avatar answered Oct 18 '22 12:10

John Feminella