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:

    [bash]yum -y install firefox Xvfb libXfont Xorg[/bash]

  2. Then, install X-desktop:

    [bash]yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"[/bash]

  3. Next, launch a XWindows Virtual Frame Buffer (XVFB) session on display port 99:

    [bash]Xvfb :99 -ac -screen 0 1280x1024x24 &[/bash]

  4. In the same terminal session, export display port:

    [bash]export DISPLAY=:99[/bash]

  5. 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]

  6. 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.

Leave a comment

Your email address will not be published. Required fields are marked *