# Class SeleniumServer

code »

    DriverService
      └ SeleniumServer

Manages the life and death of the Selenium standalone server. The server may be obtained from http://selenium-release.storage.googleapis.com/index.html.

## Constructor

SeleniumServer ( jar, options )

Parameters

jar: `string`
  Path to the Selenium server jar.
options: `!SeleniumServer.Options`
  Configuration options for the server.

Throws

`Error`
  If an invalid port is specified.

Show:Public Protected Private

## Type Definitions

code »SeleniumServer.Options : `{port: (number|!webdriver.promise.Promise.<number>), args: !(Array.<string>|webdriver.promise.Promise), jvmArgs: (!Array.<string>|!webdriver.promise.Promise|undefined), env: (!Object.<string, string>|undefined), stdio: (string|!Array|undefined)}`
Options for the Selenium server:

- `port` - The port to start the server on (must be > 0). If the port is provided as a promise, the service will wait for the promise to resolve before starting.
- `args` - The arguments to pass to the service. If a promise is provided, the service will wait for it to resolve before starting.
- `jvmArgs` - The arguments to pass to the JVM. If a promise is provided, the service will wait for it to resolve before starting.
- `env` - The environment variables that should be visible to the server process. Defaults to inheriting the current process's environment.
- `stdio` - IO configuration for the spawned server process. For more information, refer to the documentation of `child_process.spawn`.

## Instance Methods

code »address ( ) ⇒ `!webdriver.promise.Promise.<string>`

Returns

A promise that resolves to the server's address.

Throws

`Error`
  If the server has not been started.

code »isRunning ( ) ⇒ `boolean`

Returns whether the underlying process is still running. This does not take into account whether the process is in the process of shutting down.

Returns

Whether the underlying service process is running.

code »kill ( ) ⇒ `!webdriver.promise.Promise`

Stops the service if it is not currently running. This function will kill the server immediately. To synchronize with the active control flow, use `#stop()`.

Returns

A promise that will be resolved when the server has been stopped.

code »start ( opt_timeoutMs ) ⇒ `!promise.Promise.<string>`

Starts the server if it is not already running.

Parameters

opt_timeoutMs: `number=`
  How long to wait, in milliseconds, for the server to start accepting requests. Defaults to 30 seconds.

Returns

A promise that will resolve to the server's base URL when it has started accepting requests. If the timeout expires before the server has started, the promise will be rejected.

code »stop ( ) ⇒ `!webdriver.promise.Promise`

Schedules a task in the current control flow to stop the server if it is currently running.

Returns

A promise that will be resolved when the server has been stopped.

## Instance Properties

code »address_ : `promise.Promise.<string>`

Promise that resolves to the server's address or null if the server has not been started. This promise will be rejected if the server terminates before it starts accepting WebDriver requests.

code »args_ : `!(Array.<string>|webdriver.promise.Promise)`
code »command_ : `promise.Promise`

A promise for the managed subprocess, or null if the server has not been started yet. This promise will never be rejected.

code »env_ : `!Object.<string, string>`
code »executable_ : `string`
code »loopbackOnly_ : `boolean`
code »path_ : `string`
code »port_ : `(number|!webdriver.promise.Promise.<number>)`
code »stdio_ : `(string|!Array)`

## Static Properties

code »SeleniumServer.superClass_ : `DriverService.prototype`