我正在通过selenium(selenium RC)在Linux中运行Web GUI的自动化测试 . 事实上,我可以在windows中运行selenium自动化测试,结果很好,firefox可以在测试完成后自动关闭 . But when I put selenium test in linux, I found firefox can't be closed automatically after test is finished. 我知道测试脚本默认会调用 tearDown
函数,所以应该关闭firefox . 但是为什么在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 .
2 回答
问题解决了:那是因为我的firefox . 这是因为Selenium想要直接启动FireFox二进制文件,而不是委托给正常的启动脚本 . 在检查"firefox"(这是许多安装中的脚本)之前,它会检查"firefox-bin" . 但是我将firefox设置为firefox而不是firefox-bin . 更多详情请访问:Selenium not working with Firefox 3.x on linux
调用
stop()
函数应该关闭浏览器 . 如果不是,请检查启动服务器时是否使用-browserSessionReuse
.