试图配置Xvfb无头地运行Firefox

时间:2015-12-31 15:33:07

标签: ubuntu firefox xvfb headless-browser

我正在按照本教程来配置Xvfb无头地运行firefox。

http://www.alittlemadness.com/2008/03/05/running-selenium-headless/

我正在Docker镜像(ubuntu:latest)中运行这些命令,看看我是否可以在创建容器之前正确设置配置。

我对这个正在运行的命令感到困惑:

Xvfb :99 -ac

运行命令后出现这些错误:

Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension SECURITY
Initializing built-in extension XINERAMA
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in extension DOUBLE-BUFFER
Initializing built-in extension RECORD
Initializing built-in extension DPMS
Initializing built-in extension Present
Initializing built-in extension DRI3
Initializing built-in extension X-Resource
Initializing built-in extension XVideo
Initializing built-in extension XVideo-MotionCompensation
Initializing built-in extension SELinux
Initializing built-in extension GLX
[dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/Type1, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list!

我发现一个博客上有一些谷歌搜索,在这里提到这些错误:

http://veeraramkumar.blogspot.com/

我运行了这些命令:

aptitude install x11-xkb-utils
aptitude install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
aptitude install xserver-xorg-core

然而命令:

aptitude install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

给出了这个错误:

No candidate version found for xfonts-100dpi
No candidate version found for xfonts-75dpi
No candidate version found for xfonts-cyrillic
No candidate version found for xfonts-100dpi
No candidate version found for xfonts-75dpi
No candidate version found for xfonts-cyrillic
The following NEW packages will be installed:
  xfonts-scalable

然后它成功安装了xfonts-scalable。现在,当我重新运行命令时:

Xvfb :99 -ac

我只收到这些错误(最多5个错误):

[dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list!

我尝试使用apt-get查找软件包xfonts-100dpi xfonts-75dpi xfonts-cyrillic但它也声明软件包也没有安装候选软件。我需要安装哪些正确的软件包才能正确配置Xvfb以无头地运行firefox?或者我还应该做些什么呢?

感谢。

2 个答案:

答案 0 :(得分:11)

在深入研究其他类似的问题之后,一旦我重新启动了我的ubuntu docker镜像,我就能够让Xvfb正确使用以下命令。

apt-get update

apt-get install -y xorg xvfb firefox dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic

之前我在更新后错过了xorg和dbus-x11软件包。

答案 1 :(得分:3)

sudo apt-get install xvfb xfonts-100dpi xfonts-75dpi xfonts-cyrillic xorg dbus-x11

不需要重启。