Skip to content

Selenium server & browser drivers

Ondřej Machulda edited this page Apr 21, 2017 · 6 revisions

To execute Selenium tests with Steward, Selenium server must be listening on some URL. This is by default localhost:4444.

Option 1: Run Selenium server + browser driver locally 💻

1. Install Selenium server

Selenium standalone server is simply a jar file. To install (download) it. simply run in the root directory of your tests (e.g. selenium-tests/):

$ ./vendor/bin/steward install

You will be asked for version confirmation and the jar file will then be downloaded to vendor/bin/ directory.

2. Install browser driver

You will also need to download Selenium driver for the browser where you want to execute the tests. This driver is used by Selenium standalone server to start the browser of your choice - see following table for the most common browsers:

Browser Selenium driver Download link
Firefox Geckodriver download
Chrome Chromedriver download
MS Edge Microsoft WebDriver download

Download the browser driver and place the binary file (like geckodriver or chromedriver) to your PATH (eg. in /usr/bin). You can also place the file elsewhere, but then you must pass the path to the Selenium server (see below).

3. Start Selenium server

To start the Selenium server listening for incoming connections simply run:

$ java -jar ./vendor/bin/selenium-server-standalone-3.3.1.jar # the version may differ

If the browser driver binary file is not found by the Selenium server, you will need to specify the path using parameters passed to the command like this:

$ java -Dwebdriver.gecko.driver="/home/john/bin/geckodriver" -jar vendor/bin/selenium-server-standalone-3.3.1.jar
$ java -Dwebdriver.chrome.driver="/opt/chromium-browser/chromedriver" -jar vendor/bin/selenium-server-standalone-3.3.1.jar
$ java -Dwebdriver.edge.driver="C:/Path/To/MicrosoftWebDriver.exe" -jar vendor/bin/selenium-server-standalone-3.3.1.jar

If Selenium server cannot find the browser driver, it will show an error like:

The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

or

The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

Option 2: Start Selenium server + browser inside Docker 🐳

If you don't want to install and run Selenium server and the browser locally, you can run both of them in a Docker container.

The Selenium project provides many prepared official containers.

For example to start a container with Selenium server and Firefox, simply run:

$ docker run -p 4444:4444 -p 5900:5900  selenium/standalone-firefox-debug:2.53.1

This will make Selenium listening on localhost port 4444 (so this is the same as when used locally). But because the browser is inside the Docker container, you won't see it when it is started by the Selenium server. To overcome the issue, note also port 5900 is exposed for VNC. So you just need to use your favorite remote desktop viewer. For example:

$ vncviewer 127.0.0.1:5900 # if asked, password is 'secret'
Clone this wiki locally