Configuring Sahi with Xvfb
What is xvfb?
Section titled “What is xvfb?”From wikipedia (http://en.wikipedia.org/wiki/Xvfb): 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
Section titled “Installing Xvfb”Ubuntu
Section titled “Ubuntu”run apt-get install Xvfb
For Fedora
Section titled “For Fedora”run yum install Xvfb
For other linux
Section titled “For other linux”Download xvfb.tgz from http://ftp.xfree86.org/pub/XFree86/4.6.0/binaries/FreeBSD-4.x/ 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,
#!/bin/shmode=$1case "$mode" in'start')if [ -f /usr/X11R6/bin/Xvfb ]; thenecho "<strong></strong><strong>Starting up the Virtual Frame Buffer on Screen 1</strong><strong></strong>"/usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &fi;;*)echo " Usage: "echo " $0 start (start XVFB)"echo " $0 stop (stop XVFB - not supported)"exit 1;;esacexit 0- chmod +x Xvfb
Setting up Xvfb on display 1
Section titled “Setting up Xvfb on display 1”- login as
rootuser. - run following commands.
export DISPLAY=:1 firefox //for firefoxexport DISPLAY=:1 chrome //for chromestartx -- `which Xvfb` :1 -screen 0 1024x768x24&Running test in Xvfb headless browser through Sahi
Section titled “Running test in Xvfb headless browser through Sahi”-
Configure sahi/userdata/config/browser_types.xml to have browser entries as below,- Chrome:
<browserType><name>chrome-xvfb</name><displayName>Chrome</displayName><icon>chrome.png</icon><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=127.0.0.1:$port --disable-popup-blocking--always-authorize-plugins --allow-outdated-plugins --enable-npapi --incognito</options><processName>chrome</processName><force>true</force><capacity>5</capacity></browserType>
-
Firefox:
<browserType><name>firefox-xvfb</name><displayName>Firefox</displayName><icon>firefox.png</icon><path>env DISPLAY=:1 firefox -height 768 -width 1024</path><options>-profile "$userDir/browser/ff/profiles/sahi$threadNo" -no-remote</options><processName>firefox</processName><force>true</force><capacity>5</capacity></browserType>
or, on the Dashboard, click Add Browser and add the entries above before the closing 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
./testrunner.sh demo/sahi_demo.sah http://sahi.co.in/demo/ firefox-xvfb
