无法在无头 Ubuntu 服务器 9.10 中运行 Firefox

Jul*_* J. 2 ubuntu headless firefox ubuntu-9.10

我需要在我的服务器中运行 Firefox 才能从 Hudson 执行一些 Selenium 测试。我不希望必须安装完整的 gui。所以我安装了 Xvfb 以伪造 Gui(如果我的假设错误,我会以这种方式纠正我)。

经过一段时间的尝试后,我遇到了下一种情况:

$ sudo Xvfb -ac :99 &
[dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)

$ firefox
[dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!
[config/dbus] couldn't register object path
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)
(EE) config/hal: NewInputDeviceRequest failed (2)
Xlib:  extension "RANDR" missing on display ":99.0".
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details -  1: Failed to get connection to session: /bin/dbus-launch terminated abnormally without any error message)
Run Code Online (Sandbox Code Playgroud)

我正在运行 firefox 而不从存储库安装它。当我尝试运行 selenium 测试时,我遇到了套接字超时,所以我猜问题出在 Firefox 和 Xvfb 中。

我已经安装了 nex 包:

i   gconf-defaults-service                                                 - GNOME configuration database system (system defaults service) 
Run Code Online (Sandbox Code Playgroud)

在某些论坛中建议修复,在我的情况下不起作用。

在不安装完整 gui 的情况下,任何有关问题和解决方法的解释都将非常有帮助。

小智 6

你可以试试我的启动 selenium 和 Xvfb 的方法。我创建了一个 bash 脚本并将其保存为 selenium.sh

#!/bin/sh

Xvfb :0 -screen 0 1024x768x24 2>&1 >/dev/null &
出口显示=:0
java -jar /opt/selenium/selenium-server-1.0.3/selenium-server.jar -log /tmp/selenium.log

然后我按照正常运行 bash 脚本的方式运行它

$ sh 硒.sh

顺便说一句,不要忘记在 PATH 变量中包含 firefox