开发者

Selenium - "Firefox is already running" error

开发者 https://www.devze.com 2022-12-15 21:45 出处:网络
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 ses

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 windo开发者_如何转开发w, 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?


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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消