开发者

How to handle selenium crashes

开发者 https://www.devze.com 2023-02-15 09:32 出处:网络
I am currently automating tests with selenium RC which run every hour. Everything runs smoothly most of the time but there are some times where either firefox will crash or the selenium RC will just h

I am currently automating tests with selenium RC which run every hour. Everything runs smoothly most of the time but there are some times where either firefox will crash or the selenium RC will just hang and because of these two issues the testing is not continued and is stalle开发者_C百科d. Does anyone know how I can make the firefox.exe and or java.exe(selenium instance) be killed when they do crash or hang, so testing can resume. The problems I see is detecting automatically when firefox or selenium is hanging and kill it via a script automatically.

thanks!


Ideally, each of your tests will be starting from a clean state, with no existing Firefox or IE processes running. In your test tearDown() methods, you should be closing / exiting your browsers. Even with this approach, sometimes, stray processes can still creep in. If you are running your Selenium server on Windows, via Java RC, putting this command in your tests' startUp() method can help ensure no browsers / instances are running:

Runtime.getRuntime().exec("TASKKILL /F /IM Firefox.exe");
Runtime.getRuntime().exec("TASKKILL /F /IM iexplore.exe");

As far as detecting when they crash, Firefox will display an alert dialog indicating a crash. You can programatically interact with this window via external tools, such as AutoIT, which can automatically press the "OK" button on this dialog if you need. I've found that building an external AutoIT script that runs constantly in the background to handle popups, crashes, warnings, etc, is very helpful.


Not sure I have the ultimate answer for you, but I can offer some ideas:

  • Selenium will have a time-out to deal with Firefox freezing. You should double check to make sure that is set correctly and working.
  • Whatever is running your selenium (like cruise control or team city) should also have a timeout that can kill off the selenium server.
  • People often revert to rebooting their servers once a day and report positive results.(Not me)
  • I would really encourage you to figure out the root cause of this. Selenium can feel frustrating and flaky, but after digging in, I've always found it was a diagnosable problem that could be fixed (like this).

(Se pushes us to terrible extremes: We actually wrote a ssh job triggered in TeamCity that logged into a windows machine and restarted the selenium server there. Ultimately we didn't use it.)

0

精彩评论

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