Selenium and Headless Environment Selenium and Headless Environment selenium selenium

Selenium and Headless Environment


Using the X Virtual Frame Buffer (Xvfb):

We can use xvfb to create a headless environment for selenium (for example, to run over SSH).


Instructions:

  1. Start xvfb with the following options:

    $ Xvfb :89 -ac -noreset

    (where :89 is the virtual "display" created).

  2. Then, set the DISPLAY variable to be this virtual display:

    $ export DISPLAY=:89

  3. At this point, we can run the selenium server as desired. Examples follow.

Run the server Java archive:

$ java -jar selenium-server.jar

In Python:

from selenium import webdriverdriver = webdriver.Firefox()...