views:

559

answers:

3

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?

+1  A: 

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
John Feminella
I think you mean selenium.stop(), no?Also, I am actively monitoring the test - it is calling stop(), it isn't lingering, and as you said, I *hope* that indees since nothing is running on that machine other than the selenium, there are no other firefox profiles on that machine
noam
Sorry, yes, I meant `stop()`. Also, can you describe the lifecycle of what's happening? Does *every* new test bomb out this way, or does this only happen after certain tests? Under what circumstances does this happen? Is this on a Windows VM? (Edit your original question so people can provide help.)
John Feminella
I edited my question as best as I could, please tell me if there's any more data I left out.Also, I think this makes your current answer irrelevant (since the scenarios you suggest aren't possible)
noam
+1  A: 

Perhaps try setting the environment variable MOZ_NO_REMOTE to 1 (or use the -no-remote switch).

Michael Williamson
Sounds interesting. Can you please elaborate why that should fix the error?
noam
To be perfectly honest, I have no idea why this works -- only that it has fixed the same problem for me in the past. This page on the MozillaZine knowledge base seems to be the most informative page http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile
Michael Williamson
A: 

We have found that in our case the reason for this was completely unrelated to selenium - firefox itself was just having trouble because it was running on machines with not enough CPU and\or RAM. We upgraded the VM's (e.g added more RAM and CPU) and the problem went away almost completely.

noam