- First, install Xvfb:
yum -y install firefox Xvfb libXfont Xorg
- Then, install X-desktop:
yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
- Next, launch a XWindows Virtual Frame Buffer (XVFB) session on display port 99:
Xvfb :99 -ac -screen 0 1280x1024x24 &
- In the same terminal session, export display port:
- Start the Selenium server in the same terminal session that you export the DISPLAY variable:
java -jar /var/www/html/test/selenium-server-standalone.jar &
- In short, we can create a sh file to start selenium for next login sessions:
Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 java -jar /var/www/html/test/selenium-server-standalone.jar &
Done! Enjoy your TDD/BDD tasks with a headless browser 🙂
Bonus: Running webdriver with PhantomJS
- This is to use the WebDriver for CodeCeption acceptance test as guided at http://codeception.com/docs/modules/WebDriver
- Basically, just download a proper version of PhantomJS, and just run the command as in the above guide.
- One note is to be sure that there is no Xvfb as well as selenium process running at the time we start phantomjs, or it will be failed.