Linux下selenium自动化测试问题:firefox无法自动关闭
我正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题解决了:那是因为我的火狐。
发生这种情况是因为 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
调用
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.