Quick note here the necessary steps to install and run Selenium with FireFox browser in CentOS. We will need to setup XWindows for Headless Selenium with FireFox webdriver.
- First, install Xvfb:
[bash]yum -y install firefox Xvfb libXfont Xorg[/bash]
- Then, install X-desktop:
[bash]yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"[/bash]
- Next, launch a XWindows Virtual Frame Buffer (XVFB) session on display port 99:
[bash]Xvfb :99 -ac -screen 0 1280x1024x24 &[/bash]
- In the same terminal session, export display port:
[bash]export DISPLAY=:99[/bash]
- Start the Selenium server in the same terminal session that you export the DISPLAY variable:
[bash]java -jar /var/www/html/test/selenium-server-standalone.jar &[/bash]
- In short, we can create a sh file to start selenium for next login sessions:
[bash]Xvfb :99 -ac -screen 0 1280x1024x24 &
export DISPLAY=:99
java -jar /var/www/html/test/selenium-server-standalone.jar &[/bash]
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.