Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to configure Xvfb to run Firefox headlessly

I was following along this tutorial to configure Xvfb to run firefox headlessly.

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

I'm running these commands in a docker image (ubuntu:latest) currently to see if I can set up my configuration properly before creating a container.

I'm getting stuck on this command being run:

Xvfb :99 -ac

I get these errors after running the command:

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!

I found a blog with some google searching that mentions these errors here:

http://veeraramkumar.blogspot.com/

I ran these commands:

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

However the command:

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

gives this error:

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

then it successfully installs xfonts-scalable. Now when I rerun the command:

Xvfb :99 -ac

I only get these errors (down to 5 errors):

[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!

I tried to use apt-get to find the packages xfonts-100dpi xfonts-75dpi xfonts-cyrillic but it also states that the packages have no installation candidate either. What proper packages do I need to install to correctly configure Xvfb to run firefox headlessly? Or is there something else I should be doing?

Thanks.

like image 684
azemPC Avatar asked Dec 31 '15 15:12

azemPC


People also ask

How do I run Cypress without XVFB?

Running headless tests without XvfbChromium based browsers and Firefox can spawn without Xvfb when run via the --headless flag. If you're testing against either of those browsers using the --browser flag, you can opt out of Cypress spawning an X11 server by setting the environment variable ELECTRON_RUN_AS_NODE=1 .

What is XVFB browser?

Xvfb (short for X virtual framebuffer) is an in-memory display server for UNIX-like operating system (e.g., Linux). It enables you to run graphical applications without a display (e.g., browser tests on a CI server) while also having the ability to take screenshots.


2 Answers

After digging around at other similar questions I was able to get Xvfb to properly work with the following commands once I restarted my ubuntu docker image.

apt-get update

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

Previously I was missing the xorg and dbus-x11 packages after updating.

like image 94
azemPC Avatar answered Oct 21 '22 19:10

azemPC


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

Restart not needed.

like image 42
burtsevyg Avatar answered Oct 21 '22 18:10

burtsevyg