Linux下selenium自动化测试问题:firefox无法自动关闭

发布于 2024-10-05 09:14:26 字数 620 浏览 4 评论 0原文

我正在 Linux 中通过 selenium (selenium RC) 运行 Web GUI 自动化测试。事实上,我可以在windows中运行selenium自动化测试,结果很好,并且firefox可以在测试完成后自动关闭。 但是当我在linux中进行selenium测试时,我发现测试完成后firefox无法自动关闭。我知道测试脚本默认会调用tearDown函数,所以火狐浏览器应该关闭。但是为什么在Linux下,firefox不能自动​​关闭呢?

为了解决这个问题: 我重写了tearDown函数,如下所示:

public void tearDown() throws Exception
    {
        selenium.click("link=Logout");
        super.tearDown();
    }

但是在Linux中,firefox仍然无法关闭。
有人能帮我解决这个问题吗?测试完成后如何让firefox自行关闭? PS:到目前为止,我还没有找到关闭firefox的方法,顺便说一下,我使用参数-firefoxProfileTemplate来启动selenium-server.jar,因为我的Web GUI是https。

I am running automation testing for web GUI in Linux by selenium (selenium RC). In fact, I can run selenium automation test in windows, the results are fine and firefox can be closed automatically after test is finished. But when I put selenium test in linux, I found firefox can't be closed automatically after test is finished. I know the test script will call tearDown function by default, so firefox should be closed. But why in Linux, firefox can't be shutdown automatically?

To deal with this problem:
I override the tearDown function like below:

public void tearDown() throws Exception
    {
        selenium.click("link=Logout");
        super.tearDown();
    }

But in Linux, firefox still can't be closed.
Could anyone help me with this problem? How to make firefox close itself after test finished?
P.S: so far, I haven't found the way to close firefox, and by the way, I use the parameter -firefoxProfileTemplate to launch selenium-server.jar, because my web GUI is https.

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

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

发布评论

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

评论(2

听闻余生 2024-10-12 09:14:26

问题解决了:那是因为我的火狐。
发生这种情况是因为 Selenium 希望直接启动 FireFox 二进制文件,而不是委托给正常的启动脚本。在检查“firefox”(这是许多安装上的脚本)之前,它会检查“firefox-bin”。
但我将我的 Firefox 设置为由 firefox 启动,而不是由 firefox-bin 启动。
更多详细信息可以在以下位置找到:
Selenium 无法在 Linux 上与 Firefox 3.x 配合使用

Problem solved: that is because of my firefox.
This is occurring because Selenium wants to start the FireFox binary directly, rather than delegate to the normal launch script. Before checking for "firefox" (which is a script on many installations), it checks for "firefox-bin".
But I set my firefox to start by firefox not by firefox-bin.
More details could be found at:
Selenium not working with Firefox 3.x on linux

把梦留给海 2024-10-12 09:14:26

调用 stop() 函数应该关闭浏览器。如果不是,请检查启动服务器时是否使用 -browserSessionReuse

Calling the stop() function should shut down the browser. If it's not, check to see whether you are using -browserSessionReuse when starting the server.

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