Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@rxse/selenium-standalone

vvo20MIT0.15.1

installs a selenium-standalone command line to install and start a standalone selenium server

readme

Table of Contents generated with DocToc

selenium-standalone

Build Status Dependency Status devDependency Status

Command line or programmatic install and launch of selenium standalone server, chrome driver, internet explorer driver, firefox driver and phantomjs

It will install a selenium-standalone command line that will be able to install selenium server and start firefox, chrome, internet explorer or phantomjs for your tests.

npm install selenium-standalone@latest -g
selenium-standalone install
selenium-standalone start

screencast

Command line interface

# simple, use defaults and latest selenium
selenium-standalone install
selenium-standalone start

# install defaults, but silently
selenium-standalone install --silent

# specify selenium args, everything after -- is for selenium
selenium-standalone start -- -debug

# choose selenium version
selenium-standalone install --version=2.45.0 --baseURL=https://selenium-release.storage.googleapis.com

# choose chrome driver version
selenium-standalone install --drivers.chrome.version=2.15 --drivers.chrome.baseURL=https://chromedriver.storage.googleapis.com

# choose ie driver architecture
selenium-standalone start --drivers.ie.arch=ia32 --drivers.ie.baseURL=https://selenium-release.storage.googleapis.com

# install a single driver within the default list (chrome, ie, edge, firefox)
selenium-standalone install --singleDriverInstall=chrome

# specify hub and nodes to setup your own selenium grid
selenium-standalone start -- -role hub
selenium-standalone start -- -role node -hub http://localhost:4444/grid/register
selenium-standalone start -- -role node -hub http://localhost:4444/grid/register -port 5556

# If you have a complex configuration with numerous options or if you want to keep a clear configuration changes history,
# you can specify the options in a configuration file :
selenium-standalone install --config=/path/to/config.json
selenium-standalone start --config=./config/seleniumConfig.js

Config file can be a JSON file or a module file that exports options as an object:

module.exports = {
  drivers: {
    chrome: {
      version: '2.39',
      arch: process.arch,
      baseURL: 'https://chromedriver.storage.googleapis.com'
    },
  },
}

Application Programming Interface (API)

Sample configuration object

Here you can find an up-to-date example of the configuration object: lib/default-config.js

Example

var selenium = require('selenium-standalone');

selenium.install({
  // check for more recent versions of selenium here:
  // https://selenium-release.storage.googleapis.com/index.html
  version: '3.8.1',
  baseURL: 'https://selenium-release.storage.googleapis.com',
  drivers: {
    chrome: {
      // check for more recent versions of chrome driver here:
      // https://chromedriver.storage.googleapis.com/index.html
      version: '2.39',
      arch: process.arch,
      baseURL: 'https://chromedriver.storage.googleapis.com'
    },
    ie: {
      // check for more recent versions of internet explorer driver here:
      // https://selenium-release.storage.googleapis.com/index.html
      version: '3.9.0',
      arch: process.arch,
      baseURL: 'https://selenium-release.storage.googleapis.com'
    }
  },
  proxy: 'http://localproxy.com', // see https://github.com/request/request#proxies
  requestOpts: { // see https://github.com/request/request#requestoptions-callback
    timeout: 10000
  },
  logger: function(message) {

  },
  progressCb: function(totalLength, progressLength, chunkLength) {

  }
}, cb);

selenium.install([opts,] cb)

opts.version selenium version to install.

opts.drivers map of drivers to download and install along with selenium standalone server.

The current defaults can be found in lib/default-config.js.

arch is either ia32 or x64, it's here because you might want to switch to a particular arch sometimes.

baseURL is used to find the server having the selenium or drivers files.

opts.basePath sets the base directory used to store the selenium standalone .jar and drivers. Defaults to current working directory + .selenium/

opts.progressCb(totalLength, progressLength, chunkLength) will be called if provided with raw bytes length numbers about the current download process. It is used by the command line to show a progress bar.

opts.logger will be called if provided with some debugging information about the installation process.

opts.requestOpts can be any valid request options object. You can use this for example to set a timeout.

cb(err) called when install finished or errored.

selenium.start([opts,] cb)

opts.version selenium version to install.

opts.drivers map of drivers to run along with selenium standalone server, same as selenium.install.

opts.basePath sets the base directory used to load the selenium standalone .jar and drivers, same as selenium.install.

By default all drivers are loaded, you only control and change the versions or archs.

opts.spawnOptions spawn options for the selenium server. Defaults to undefined

opts.javaArgs array of arguments for the JVM, included between java and -jar in the command line invocation. Use this option to set properties like -Xmx=512M or -Djava.util.logging.config.file=logging.properties, for instance. Defaults to [].

opts.seleniumArgs array of arguments for the selenium server, passed directly to child_process.spawn. Defaults to [].

opts.spawnCb will be called if provided as soon as the selenium child process was spawned. It may be interesting if you want to do some more debug.

opts.javaPath set the javaPath manually, otherwise we use [which](https://github.com/isaacs/node-which).sync('java').

opts.requestOpts can be any valid request options object. You can use this for example to set a timeout.

cb(err, child) called when the server is running and listening, child is the ChildProcess instance created.

So you can child.kill() when you are done.

Error: Another Selenium process is already running

If you're getting this error, it means that you didn't shut down the server successfully the last time you started it, so it's still running in the background. You can kill it by running:

pkill -f selenium-standalone

Available browsers

By default, google chrome, firefox and phantomjs are available when installed on the host system.

Tips

Start Selenium whenever your (ubuntu) machine starts!

After installing selenium-standalone globally, execute the following commands to run selenium-standalone when your machine starts!

ln -s /usr/local/bin/selenium-standalone /etc/init.d/
update-rc.d selenium-standalone defaults

For more information: https://stackoverflow.com/questions/3666794/selenium-server-on-startup/30392437#30392437

Ensure you have the minimum required Java version

With the release of Selenium 3+, the minimum required version of Java is 8, as 7 has ceased public updates.

If an older selenium version is needed, you can check the requirements on the official Selenium changelog.

Here is a reference sheet for the more recent Selenium version:

Selenium version Minimum Java Required
3.0.0+ Java 8
2.47.0+ Java 7
2.22.0+ Java 6

Running headlessly

On linux,

To run headlessly, you can use xvfb:

xvfb-run --server-args="-screen 0, 1366x768x24" selenium-standalone start

Logging

Selenium Process

By default, Selenium sends logging messages to stderr.

The selenium-standalone cli tool (selenium-standalone start) will output the logging messages to your process.stderr. So you do see them in the console.

If you are using the programmatic API, you can retrieve the stderr messages by doing this:

var selenium = require('selenium-standalone');
selenium.start(function(err, child) {
  child.stderr.on('data', function(data){
    console.log(data.toString());
  });
});

You can also forward the stderr to your process.stderr like the cli does:

var selenium = require('selenium-standalone');
selenium.start({
  spawnOptions: {
      stdio: 'inherit'
  }
}, function(err, child) {
  // child.stderr now sent to your `process.stderr`
});

Debug Logs for Selenium Standalone Process

At times you may need to get debug logs for what selenium-standalone is doing. In your environment variables set DEBUG=selenium-standalone:*. This will enable extra log statements to be shown in stderr.

Example:

$ DEBUG=selenium-standalone:* selenium-standalone install --drivers.chrome.version=2.15
  selenium-standalone:env-details Platform: darwin +0ms
  selenium-standalone:env-details Architecture: x64 +3ms
  selenium-standalone:env-details Node.js: v6.9.4 +2ms
  selenium-standalone:cli Started via CLI with:  [ '/usr/local/bin/node',
  '/tmp/selenium-standalone/bin/selenium-standalone',
  'install',
  '--drivers.chrome.version=2.15' ]
  ...

Examples of combining with other tools

Docker

  1. git clone git@github.com:vvo/selenium-standalone.git
  2. cd selenium-standalone
  3. docker build -f Dockerfile -t vvo/selenium-standalone . --rm
  4. docker run -p 4444:4444 vvo/selenium-standalone

Release

npm run release [major|minor|patch|x.x.x]

Error: unable to get local issuer certificate

This error might happen when you are behind a specific proxy. Then you need to set some environement variables:

NODE_TLS_REJECT_UNAUTHORIZED=0 selenium-standalone install`
NODE_TLS_REJECT_UNAUTHORIZED=0 selenium-standalone start

On Windows:

setx NODE_TLS_REJECT_UNAUTHORIZED 0

changelog

6.15.1 (2018-06-19)

  • Updated Selenium to 3.12.0
  • Updated ChromeDriver to 2.40
  • Updated IEDriver to 3.12.0
  • Updated GeckoDriver to 0.20.1
  • Updated EdgeDriver to 17134
  • Added Docker support for Linux
  • Fixed tests, live tests still failing on Travis CI (timeouts).

6.12.0 (2017-12-05)

  • Update default selenium to 3.7.1 (#327)
  • Update default IEDriver to 3.7.1 (#327)
  • Update default geckodriver to 0.19.1 (#327)
  • Update default Edge driver to 16299 (#330)
  • Update downstream dependencies

6.11.0 (2017-10-20)

  • Update default selenium to 3.6.0 (#310)
  • Update default chromedriver to 2.33 (#310)
  • Update default geckodriver to 0.19.0 (#310)
  • Update default IEDriver to 3.6.0 (#310)
  • Ability to install only one driver from default list (#313)

6.10.0 (2017-10-07)

  • Fix selenium server status check URL when passing node config file (#308)
  • Add timeout option to download request (#309)

6.9.0 (2017-09-04)

  • Update default selenium to 3.5.3 (#302)
  • Update default chromedriver to 2.32 (#302)

6.8.0 (2017-08-28)

  • Update default selenium to 3.5.2 (#301)
  • Update default IEDriver to 3.5.1 (#301)

6.7.0 (2017-08-15)

  • Update default selenium to 3.5.0 (#296)
  • Update default IEDriver to 3.5.0 (#296)
  • Update default geckodriver to 0.18.0 (#295)

6.6.0 (2017-07-28)

  • Update default chromedriver to 2.31 (#290)

6.5.0 (2017-06-08)

  • Ability to install Microsoft Edge driver (#284)
  • Update default chromedriver to 2.30 (#285)

6.4.1 (2017-04-24)

  • Fix seleniumArgs handling in config file

6.4.0 (2017-04-24)

  • Update selenium to 3.4.0
  • Update IEDriver to 3.4.0
  • Update geckodriver to 0.16.0

6.3.0 (2017-04-21)

  • Update default chromedriver to 2.29 (#274)
  • Update default IEDriver to 3.3.0 (#274)

6.2.0 (2017-04-05)

  • Update default Selenium Server to 3.3.1 (#273)
  • Update default Firefox driver to 0.15.0 (#273)
  • Ability to collect debug logs for bug reports (#271)

6.1.0 (2017-03-17)

  • Update default chromedriver to 2.28 (#267).

6.0.1 (2017-02-01)

  • Fix default version for IEDriver to 3.0.0.

6.0.0 (2017-01-29)

  • BREAKING CHANGE Using selenium 3.0.1 (Java 8 is needed)
  • Using yarn as package manager
  • Updated dependencies

5.11.2 (2017-01-26)

  • Fix support for Node.JS v0.12

5.11.1 (2017-01-17)

  • Update request and mocha dependencies.

5.11.0 (2017-01-17)

  • update geckodriver to v0.13.0

5.10.0 (2017-01-16)

  • update chromedriver version to 2.27
  • --config file option

5.9.1 (2017-01-07)

  • Fix incorrect download urls for Firefox drivers (#251)

5.9.0 (2016-12-04)

  • update geckodriver to v0.11.1

5.8.0 (2016-10-26)

  • update chrome driver to 2.25 #240
  • add opts.javaArgs #234

5.7.2 (2016-09-22)

  • fix expectedRequest when less drivers given than usual

5.7.1 (2016-09-16)

5.7.0 (2016-09-16)

  • really fix selenium 3 install feature
  • add tests around computing the download urls
  • switch to new chromedriver 2.24

5.6.4 (2016-09-15)

  • Handle geckodriver/Marionette urls weirdness (#222)

5.6.3 (2016-09-09)

  • Support geckodriver v0.9.0 and v0.8.0 (6ef046448db058845aac709e839894ac95c65053)

    5.6.2 (2016-08-29)

  • allow beta versions of selenium to be used #206
  • allow installing old chrome driver versions #213

5.6.1 (2016-08-23)

  • update download path for firefox driver 0.10.0 on mac

5.6.0 (2016-08-23)

  • upgrade chromedriver to 2.23
  • upgrade firefox driver to 0.10.0
  • better error message when java is possibly outdated

5.5.0 (2016-07-08)

  • add proxy option to programmatic interface

5.4.1 (2016-07-06)

  • fix install script when geckodriver downloaded

5.4.0 (2016-07-01)

  • update geckodriver to v0.9.0
  • update selenium to 2.53.1

5.3.1 (2016-06-28)

5.3.0 (2016-06-28)

  • fix firefox win32 download url

5.2.0 (2016-06-28)

  • add marionette driver
  • bump chromedriver

5.1.1 (2016-06-10)

5.1.0 (2016-03-23)

  • update to latest versions

5.0.0 (2016-02-24)

  • BREAKING CHANGE when opts.drivers are passed on the programmatic interface, do not merge all drivers option, only the one passed. So if you use {drivers: {chrome: {version: 42}}}, you will only get chrome version 42, not IE, not firefox

4.9.1 (2016-02-20)

  • node 0.10 compat for fs.access

4.9.0 (2016-02-02)

4.8.0 (2015-12-08)

  • feat(paths): support basePath option
  • feat(https): use https downloads by default

4.7.2 (2015-11-23)

  • fix(hub): selenium-standalone can now be run as hub

4.7.1 (2015-10-22)

  • fix(version): treat version as strings to allow 2.20 version, fixes #142

4.7.0 (2015-09-30)

  • feat(install): add install --silent

4.6.3 (2015-09-25)

  • fix require urijs

4.6.2 (2015-09-25)

  • update urijs package (renamed)

4.6.1 (2015-09-01)

  • release: do not include .selenium in package

4.6.0 (2015-09-01)

  • feat: selenium 2.47.1, ie driver 2.47.0, chrome 2.18
  • fix: fix default IE driver download url computation
  • fix: only append default stderr stdout listeners if not added by user

4.5.3 (2015-07-06)

  • feat: update to latest selenium/drivers version

4.4.3 (2015-07-06)

  • fix: error if already started

4.4.2 (2015-05-25)

  • fix: programmatic usage was broken

4.4.1 (2015-05-25)

  • fix: use isaacs/node-which instead of vvo/whereis to find JAVA path
    • fixes #96
  • fix: better handle selenium started event (when roles are hub or node)
    • fixes #98
    • fixes #97

4.4.0 (2015-04-17)

  • upgrade chrome driver to 2.15

4.3.0 (2015-04-17)

  • parse selenium's -hub argument to find the hub hostname

4.2.2 (2015-03-23)

  • fix selenium binary start

4.2.1 (2015-03-20)

  • FIX: flush stderr/stdout of selenium so that it does not fails

4.2.0 (2015-03-02)

  • upgrade to selenium 2.45.0

4.1.0 (2015-02-06)

  • update chrome driver to 2.14

4.0.0 (2015-02-06)

  • cache downloads, see #68

3.3.0 (2015-02-03)

  • forward request error to install error, #64

3.2.0 (2015-01-23)

  • add --baseURL, --drivers.*.baseURL options, also in programmatic API

3.1.2 (2015-01-17)

  • try to force npm to publish

3.1.1 (2015-01-17)

  • fixes #60, programmatic install without a progressCb

3.1.0 (2015-01-17)

  • add opts.logger to install(), defaults to noop
  • add opts.progressCb to install(opts), now you can receive progress information
  • log more info when installing: source, destination
  • show progress when installing
  • check for pathsexistence before starting and error accordingly
  • add opts.spawnCb to start(), now you can receive the spawned process asap
  • more tests
  • readme tweaks

3.0.3 (2015-01-10)

  • inform user that start-selenium is deprecated

3.0.2 (2015-01-10)

  • ie fix

3.0.1 (2015-01-10)

  • ie fix

3.0.0 (2015-01-10)

  • complete refactoring
  • command line is now named selenium-standalone
  • you must use selenium-standalone install and then selenium-standalone start
  • programmatic API changed too, require('selenium-standalone').install(cb) or require('selenium-standalone').start(cb)
  • using the programmatic API, you must kill the server yourself, the child_process is sent in the start callback: cb(err, cp)
  • you can now install and start different selenium versions and drivers versions

2.44.0-7 (2015-01-04)

  • fix start-selenium when port is not 4444

2.44.0-6 (2015-01-03)

  • add tests on new cb() functionnality
  • backward compat for people not using a cb
  • lower down callback loop to 200ms

2.44.0-5 (2015-01-03)

  • fix start-selenium command line (missing callback)

2.44.0-4 (2015-01-02)

  • programmatic API now exposes a callback to inform when selenium has started

2.44.0-3 (2015-01-02)

  • update chromedriver to 2.13

2.44.0-2 (2015-01-02)

  • initial history generation