Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

I am running selenium through Xvfb on display number: 99 like this:

/usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 & export DISPLAY=":99" && java -jar /usr/lib/selenium/selenium-server-standalone-2.24.1.jar -port 4444

However, display with a number other than 0 is not visible by default. How do I make it visible to actually see what selenium is doing in the browser?

1 Answer

0 votes
by (62.9k points)

All you need is to install x11vnc via:

sudo apt-get install x11vnc xvfb fluxbox

Optionally install Fluxbox to have a simple window manager.

Then to do the setup the access to Xvfb for remote control can be done using X11 over SSH or VNC over SSH, e.g.

export DISPLAY=:1

Xvfb $DISPLAY -screen 0 1024x768x16 &

fluxbox &

x11vnc -display $DISPLAY -bg -forever -nopw -quiet -listen localhost -xkb

Here is script friendly version:

export DISPLAY=$ # Select screen 0 by default.


if which x11vnc &>/dev/null; then

! pgrep -a x11vnc && x11vnc -bg -forever -nopw -quiet -display WAIT$DISPLAY &


! pgrep -a Xvfb && Xvfb $DISPLAY -screen 0 1024x768x16 &

sleep 1

if which fluxbox &>/dev/null; then

! pgrep -a fluxbox && fluxbox 2>/dev/null &


echo "IP: $(hostname -I) ($(hostname))"


If your Xvfb listens on localhost only, you can setup tunneling to localhost, so a vncviewer can then be used to connect to the localhost to get the remote control over the server. E.g.

ssh -N -T -L 5900:localhost:5900 [email protected] &

vncviewer -encodings 'copyrect tight zrle hextile' localhost:5900

Or to listen on all addresses with passwords, use:

x11vnc -display :0.0 -usepw

To set up a password, run x11vnc -storepasswd.

See: remote control over SSH at Xvfb Wikipedia page

Or you can use the following one-liner:

$ x11vnc -create -env FD_PROG=/usr/bin/fluxbox \



-gone 'killall Xvfb' \

-bg -nopw

-create makes it start Xvfb

X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 makes it go to the created Xvfb session (Display: 1 rather than :0 which will be in desktop)

FD_PROG=/usr/bin/fluxbox makes it fire up Fluxbox (Ubuntu's Fluxbox, should have background Ubuntu logo)

X11VNC_CREATE_GEOM==${1:-1024x768x16} sets screen to 16bit colour 1024x768

-gone cleans up once it exits, otherwise, Xvfb is left behind. (As  killing xvfb additionally kills fluxbox)

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories