如何处理硒崩溃
我目前正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理想情况下,您的每个测试都将从干净的状态开始,没有任何现有的 Firefox 或 IE 进程在运行。在您的测试tearDown()方法中,您应该关闭/退出浏览器。即使使用这种方法,有时,杂散进程仍然会悄悄出现。如果您在 Windows 上通过 Java RC 运行 Selenium 服务器,将此命令放入测试的 startUp() 方法中可以帮助确保没有浏览器/实例正在运行
:当检测到崩溃时,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:
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.
不确定我是否能为您提供最终答案,但我可以提供一些想法:
(Se 将我们推向可怕的极端:我们实际上编写了一个在 TeamCity 中触发的 ssh 作业,该作业登录到 Windows 计算机并在那里重新启动 selenium 服务器。最终我们没有使用它。)
Not sure I have the ultimate answer for you, but I can offer some ideas:
(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.)