read

For a latest project, I needed to run node-webkit on an EC2 ubuntu instance. Since, I do not have a display, I needed to create a virtual display as follows.

Install essential packages for XVFB

Let’s install the required packages. The fonts aren’t really necessary but installing them prevents you from getting annoying warnings. xvfb can start a virtual X window on a server where Selenium can start the browser in to run your tests.

sudo apt-get update && sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic xvfb x11-apps imagemagick

Create script for starting XVFB

To start xvfb I like to have a little start/stop script like this one:

#!/bin/bash
if [ -z "$1" ]; then
  echo "`basename $0` {start|stop}"
  exit
fi

case "$1" in
start)
  /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 &
;;
stop)
  killall Xvfb
;;
esac

This will start a Window on display :99. This is important later on. Place the script in /etc/init.d/. To start it automatically on boot, run: sudo update-rc.d xvfb defaults.

Start and stop XVFB

First lets start xvfb
sudo /etc/init.d/xvfb start

Now we have to set the DISPLAY env variable so Firefox and Chrome know where to open the browser.
export DISPLAY=:99

Now, your node-webkit app should run without any problem using the virtual X window!

PS: Many thanks to the author of the post called Installing Selenium with Jenkins on Ubuntu - LexTech

Blog Logo

Santosh

Ghost Lover!


Published

Image

Random Thoughts!

Fast and Mobile Life!

Back to Overview