我正在通过 selenium (selenium RC) 在 Linux 中运行 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自行关闭?
P.S: 到目前为止,我还没有找到关闭firefox的方法,顺便说一句,我使用参数-firefoxProfileTemplate来启动selenium-server.jar,因为我的web GUI是https。
最佳答案
问题解决了:那是因为我的firefox。 这是因为 Selenium 想要直接启动 FireFox 二进制文件,而不是委托(delegate)给正常的启动脚本。在检查“firefox”(这是许多安装的脚本)之前,它会检查“firefox-bin”。 但是我将我的 firefox 设置为由 firefox 而不是 firefox-bin 启动。 可以在以下位置找到更多详细信息: Selenium not working with Firefox 3.x on linux
关于linux - Linux selenium自动化测试问题: firefox can't be closed automatically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4343043/