如何处理硒崩溃

发布于 2024-10-21 03:37:08 字数 239 浏览 3 评论 0原文

我目前正在使用 selenium RC 进行自动化测试,该测试每小时运行一次。大多数时候一切都运行顺利,但有时 Firefox 会崩溃,或者 Selenium RC 会挂起,并且由于这两个问题,测试无法继续并陷入停滞。有谁知道如何让 firefox.exe 和/或 java.exe(selenium 实例)在崩溃或挂起时被杀死,以便测试可以恢复。我看到的问题是自动检测 Firefox 或 Selenium 何时挂起并通过脚本自动杀死它。

谢谢!

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 stalled. 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走过海棠暮 2024-10-28 03:37:08

理想情况下,您的每个测试都将从干净的状态开始,没有任何现有的 Firefox 或 IE 进程在运行。在您的测试tearDown()方法中,您应该关闭/退出浏览器。即使使用这种方法,有时,杂散进程仍然会悄悄出现。如果您在 Windows 上通过 Java RC 运行 Selenium 服务器,将此命令放入测试的 startUp() 方法中可以帮助确保没有浏览器/实例正在运行

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

:当检测到崩溃时,Firefox 将显示一个警告对话框,指示崩溃。您可以通过外部工具(例如 AutoIT)以编程方式与此窗口进行交互,如果需要,它可以自动按此对话框上的“确定”按钮。我发现构建一个在后台不断运行的外部 AutoIT 脚本来处理弹出窗口、崩溃、警告等非常有帮助。

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.

傲娇萝莉攻 2024-10-28 03:37:08

不确定我是否能为您提供最终答案,但我可以提供一些想法:

  • Selenium 将有一个超时来处理 Firefox 冻结问题。您应该仔细检查以确保设置正确并且正常工作。
  • 无论运行您的硒的是什么(例如巡航控制或团队城市)也应该有一个可以终止硒服务器的超时。
  • 人们经常恢复每天重新启动服务器一次并报告积极的结果。(不是我)
  • 我真的鼓励您找出造成这种情况的根本原因。硒可能会让人感到沮丧和脆弱,但在深入研究之后,我总是发现这是一个可以修复的可诊断问题(例如 这个)。

(Se 将我们推向可怕的极端:我们实际上编写了一个在 TeamCity 中触发的 ssh 作业,该作业登录到 Windows 计算机并在那里重新启动 selenium 服务器。最终我们没有使用它。)

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文