Sahi Documentation

Configuring Sahi with Xvfb

warning NOTE: We do not recommend headless execution. Troubleshooting scripts in a headless environment can be tricky.
warning If you are looking at headless execution for integration with your CI server, read our recommended Jenkins/CI setup without headless playback.

What is xvfb?

From wikipedia ( Xvfb or X virtual framebuffer is an X11 server that performs all graphical operations in memory, not showing any screen output. From the point of view of the client, it acts exactly like any other server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to even have a screen or any input device. Only a network layer is necessary.

Installing Xvfb


run apt-get install Xvfb

For Fedora

run yum install Xvfb

For other linux

Download xvfb.tgz from Let us consider that the downloaded file is at ~/Downloads. 1) cd / 2) tar xvf ~/Downloads/xvfb.tgz 3) cd /usr 4) sudo mkdir X11R6 5) sudo cp ~/Downloads/xvfb/. /usr/X11R6/ 6) chmod +x bin/Xvfb 7) cd bin 8) create a new file Xvfb and add the below script,
case "$mode" in
if [ -f /usr/X11R6/bin/Xvfb ]; then
echo "<strong></strong><strong>Starting up the Virtual Frame Buffer on Screen 1</strong><strong></strong>"
/usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &
echo " Usage: "
echo " $0 start (start XVFB)"
echo " $0 stop (stop XVFB - not supported)"
exit 1
exit 0
9) chmod +x Xvfb

Setting up Xvfb on display 1

  • login as root user.
  • run following commands.
  • export DISPLAY=:1 firefox //for firefox
    export DISPLAY=:1 chrome //for chrome
    startx -- `which Xvfb` :1 -screen 0 1024x768x24&
  • if you get following error:
  • then run
    startx -- `[Xvfb Path]` :1 -screen 0 1024x768x24&
  • for [Xvfb Path] run
  • which Xvfb
  • Example:
    startx -- `/bin/Xvfb` :1 -screen 0 1024x768x24&
  • Running test in Xvfb headless browser through Sahi

    1) Configure sahi/userdata/config/browser_types.xml to have browser entries as below,
  • Chrome:
         <path>env DISPLAY=:1 google-chrome --no-sandbox --no-default-browser-check --no-first-run --start-maximized</path>
         <options>--user-data-dir=$userDir/browser/chrome/profiles/sahi$threadNo --proxy-server=$port --disable-popup-blocking
                         --always-authorize-plugins --allow-outdated-plugins --enable-npapi --incognito</options>
  • Firefox:
         <path>env DISPLAY=:1 firefox -height 768 -width 1024</path>
         <options>-profile "$userDir/browser/ff/profiles/sahi$threadNo" -no-remote</options>
  • or Click on "Configure" link on Dashboard, and add the above entries before the ending tag in browser_types.xml 2) Save and restart Sahi. 3) To run a test in Xvfb: navigate to sahi/userdata/bin on terminal and run the command
    ./ demo/sahi_demo.sah firefox-xvfb