Selenium在Ubuntu上启动Firefox时挂起 [英] Selenium hangs when launching Firefox on Ubuntu
问题描述
我的Jenkins安装在Ubuntu虚拟机中运行。
在jenkins selenium设置发生了一些问题(源于jenkins运行的用户权限)之后,切换到从命令行运行命令,看看发生了什么。我的目标是让测试在这里运行,然后在Jenkins中运行。
下面是我正在使用和看到的命令和响应。 >
resn @ resn-VirtualBox:〜$ sudo java -jar /var/lib/jenkins/tools/selenium/selenium-server.jar - htmlSuite * firefox http://google.com/ var / lib / jenkins / jobs / Selenium setup test / workspace / tests / test-testsuite.html/ var / lib / jenkins / jobs / Selenium setup test / workspace / results / results.html-log = / tmp / selenium.log -debug = true -firefoxProfileTemplate/home/resn/.mozilla/firefox/6f2um01h.Selenium
23/08/2011 11 :19:51 AM org.openqa.grid.selenium.GridLauncher main
INFO:启动一个独立服务器
11:19:52.172信息 - Java:Sun Microsystems Inc. 19.0-b09
11 :19:52.173 INFO - 操作系统:Linux 2.6.35-28 - 通用i386
11:19:52.223信息 - v2.4.0,与核心v2.4.0。从版本13337构建
11:19:52.488信息 - RemoteWebDriver实例应该连接到:http://127.0.0.1:4444/wd/hub
11:19:52.491信息 - 版本Jetty / 5.1。 x
11:19:52.491 INFO - 启动HttpContext [/ selenium-server / driver,/ selenium-server / driver]
11:19:52.501 INFO - 启动HttpContext [/ selenium-server / selenium -server]
11:19:52.501 INFO - 启动HttpContext [/,/]
11:19:52.520信息 - 已启动org.openqa.jetty.jetty.servlet.ServletHandler@15b7986
11:19:52.521 INFO - 启动HttpContext [/ wd,/ wd]
11:19:52.530 INFO - 在0.0.0.0:4444
11:19:52.530上启动SocketListener信息 - 已启动org.openqa .jetty.jetty.Server @ 54172f
11:19:53.379信息 - 准备Firefox配置文件...
11:19:55.949信息 - 启动Firefox ...
$ c $ Ubuntu的虚拟机不是一个无头的实例,所以AFAIK我不需要安装xvfb(正如在一些博客文章中提到的同样的话题)。
在这个问题之前,我哈哈d Firefox配置文件的一个问题,我使用我在这里回答的方法修复了这个问题:
<使用应用程序菜单中的快捷方式启动Firefox,并在命令行上输入'firefox'即可打开Firefox。
我尝试添加完整路径到Firefox应用程序,以许多方式:
- 在命令'... * firefox /usr/lib/firefox-3.6.20 / firefox.sh ...导致无法找到HTML Suite文件:/ home / resn / http:/google.com: - 它似乎得到了与下一个参数混合的Firefox路径
-
在命令中,没有空格...firefox / usr / lib / firefox-3.6.20 / firefox.sh ... b
$ b
HTML套件异常情况:
java.lang.RuntimeException:浏览器不支持:* firefox / usr / lib / firefox-3.6.20 / firefox.sh
支持的浏览器包括:
* firefox
- 在grid_configuration.yml'... browser:* firefox /usr/lib.firefox-3.6.20/firefox.sh。这并没有什么影响。
此外,由于进程只是挂起,并没有真正的失败,日志文件(
$ b 任何想法,提示或调试建议都将非常受欢迎!解决方案这个问题似乎是在无头环境下运行的。如果你没有窗口来渲染你的浏览器,它会挂起。你可以通过在你的机器上粘贴相同的命令来测试它,而是使用ssh -X me@server.com
我发现了这个文档要解决这个问题:
http://www.alittlemadness .com / 2008/03/05 / running-selenium-headless /
My end goal is to have Selenium running 'within' Jenkins.
My Jenkins installation runs within an Ubuntu virtual machine.
After some issues with the jenkins selenium setup (stemming from permissions for the user that jenkins runs under) I switched to running the command from the command line to see what was happening. My aim is to get the test running here, and then to get it working within Jenkins.
Here's the command and responses I'm currently using and seeing.
resn@resn-VirtualBox:~$ sudo java -jar /var/lib/jenkins/tools/selenium/selenium-server.jar -htmlSuite *firefox http://google.com "/var/lib/jenkins/jobs/Selenium setup test/workspace/tests/test-testsuite.html" "/var/lib/jenkins/jobs/Selenium setup test/workspace/results/results.html" -log=/tmp/selenium.log -debug=true -firefoxProfileTemplate "/home/resn/.mozilla/firefox/6f2um01h.Selenium"
23/08/2011 11:19:51 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
11:19:52.172 INFO - Java: Sun Microsystems Inc. 19.0-b09
11:19:52.173 INFO - OS: Linux 2.6.35-28-generic i386
11:19:52.223 INFO - v2.4.0, with Core v2.4.0. Built from revision 13337
11:19:52.488 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
11:19:52.491 INFO - Version Jetty/5.1.x
11:19:52.491 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
11:19:52.501 INFO - Started HttpContext[/selenium-server,/selenium-server]
11:19:52.501 INFO - Started HttpContext[/,/]
11:19:52.520 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@15b7986
11:19:52.521 INFO - Started HttpContext[/wd,/wd]
11:19:52.530 INFO - Started SocketListener on 0.0.0.0:4444
11:19:52.530 INFO - Started org.openqa.jetty.jetty.Server@54172f
11:19:53.379 INFO - Preparing Firefox profile...
11:19:55.949 INFO - Launching Firefox...
The Ubuntu virtual machine is not a headless instance, so AFAIK I don't need to install xvfb (as is mentioned in some blog posts on the same topic).
Previous to this issue, I had an issue with Firefox profiles, which I fixed using the approach I answered with here : Jenkins can't launch selenium tests (Timed out waiting for profile to be created)
Firefox opens fine when launched using the shortcut within the Applications menu, and from just entering 'firefox' on the command line.
I've tried adding the full path to the Firefox application, in numerous ways :
- In the command '... *firefox /usr/lib/firefox-3.6.20/firefox.sh ..." Which results in "Can't find HTML Suite file:/home/resn/http:/google.com:" - it seems to get the firefox path mixed up with the next parameter
In the command, without a space '... "firefox/usr/lib/firefox-3.6.20/firefox.sh ...' Which results in
"HTML suite exception seen:
java.lang.RuntimeException: Browser not supported: *firefox/usr/lib/firefox-3.6.20/firefox.sh
Supported browsers include:
*firefox"
- In grid_configuration.yml ' ... browser: "*firefox /usr/lib.firefox-3.6.20/firefox.sh". Which didn't have any impact.
Also, because the process just hangs, and doesn't actually fail, the log file (/tmp/selenium.log) isn't created.
Any ideas, tips or debugging suggestions would be very welcome!
解决方案 The problem seems to be when running in a headless environment. If you don't have a window for it to render your browser in, it will hang. You can test this by pasting the same command when you ssh into your machine, but instead do ssh -X me@server.com
I found this documentation on what you can do to fix this:
http://www.alittlemadness.com/2008/03/05/running-selenium-headless/
这篇关于Selenium在Ubuntu上启动Firefox时挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!