Module: selenium-webdriver/remote
View Source

# class DriverService

Manages the life and death of a native executable WebDriver server.

It is expected that the driver server implements the https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol. Furthermore, the managed server should support multiple concurrent sessions, so that this class may be reused for multiple clients.

### new DriverService(executable, options)

Parameters

executable`string`

  Path to the executable to run.

options`{args: (Array<string>|webdriver.promise.Promise), env: (Object<string, string>|undefined), loopback: (boolean|undefined), path: (string|undefined), port: (number|webdriver.promise.Promise), stdio: (string|Array<?(string|number|Stream)>|undefined)}`

  Configuration options for the service.

## Instance Methods

### address()code »

Returns

`webdriver.promise.Promise`

  A promise that resolves to the server's address.

Throws

`Error`

  If the server has not been started.

### isRunning()code »

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

`boolean`

  Whether the underlying service process is running.

### kill()code »

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

`webdriver.promise.Promise`

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

### start(opt_timeoutMs)code »

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

`webdriver.promise.Promise`

  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.

### stop()code »

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

Returns

`webdriver.promise.Promise`

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

## Static Properties

DriverService.DEFAULT_START_TIMEOUT_MS `number`

  The default amount of time, in milliseconds, to wait for the server to start.