Running Selenium with FireFox browser in CentOS

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.

  1. First, install Xvfb:
    yum -y install firefox Xvfb libXfont Xorg
  2. Then, install X-desktop:
    yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
  3. Next, launch a XWindows Virtual Frame Buffer (XVFB) session on display port 99:
    Xvfb :99 -ac -screen 0 1280x1024x24 &
  4. In the same terminal session, export display port:
    export DISPLAY=:99
  5. 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 &
  6. 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.

Leave a Reply