-
Notifications
You must be signed in to change notification settings - Fork 40
Selenium server & browser drivers
To execute Selenium tests with Steward, Selenium server must be started to listen on some port. This is by default localhost:4444
. There are two main options how you can accomplish this:
Selenium standalone server is simply a jar file. To install (download) it, just 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.
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).
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 you want to use Selenium with Firefox, make sure to disable the "pass through" mode:
$ java -jar ./vendor/bin/selenium-server-standalone-3.7.0.jar -enablePassThrough false
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
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:3.141.59-20210128
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 VNC viewer. For example:
$ vncviewer 127.0.0.1:5900 # if asked enter password 'secret'