# Class ServiceBuilder

code »

Creates `remote.DriverService` instances that manage a ChromeDriver server.

## Constructor

ServiceBuilder ( opt_exe )

Parameters

opt_exe: `string=`
  Path to the server executable to use. If omitted, the builder will attempt to locate the chromedriver on the current PATH.

Throws

`Error`
  If provided executable does not exist, or the chromedriver cannot be found on the PATH.

Show:PublicProtectedPrivate

## Instance Methods

code » build ( ) ⇒ `remote.DriverService`

Creates a new DriverService using this instance's current configuration.

Returns

A new driver service using this instance's current configuration.

Throws

`Error`
  If the driver exectuable was not specified and a default could not be found on the current PATH.

code » enableVerboseLogging ( ) ⇒ `!ServiceBuilder`

Enables verbose logging.

Returns

A self reference.

code » loggingTo ( path ) ⇒ `!ServiceBuilder`

Sets the path of the log file the driver should log to. If a log file is not specified, the driver will log to stderr.

Parameters

path: `string`
  Path of the log file to use.

Returns

A self reference.

code » setNumHttpThreads ( n ) ⇒ `!ServiceBuilder`

Sets the number of threads the driver should use to manage HTTP requests. By default, the driver will use 4 threads.

Parameters

n: `number`
  The number of threads to use.

Returns

A self reference.

code » setStdio ( config ) ⇒ `!ServiceBuilder`

Defines the stdio configuration for the driver service. See `child_process.spawn` for more information.

Parameters

config: `(string|!Array)`
  The configuration to use.

Returns

A self reference.

code » setUrlBasePath ( path ) ⇒ `!ServiceBuilder`

Sets the base path for WebDriver REST commands (e.g. "/wd/hub"). By default, the driver will accept commands relative to "/".

Parameters

path: `string`
  The base path to use.

Returns

A self reference.

code » usingPort ( port ) ⇒ `!ServiceBuilder`

Sets the port to start the ChromeDriver on.

Parameters

port: `number`
  The port to use, or 0 for any free port.

Returns

A self reference.

Throws

`Error`
  If the port is invalid.

code » withEnvironment ( env ) ⇒ `!ServiceBuilder`

Defines the environment to start the server under. This settings will be inherited by every browser session started by the server.

Parameters

env: `!Object.<string, string>`
  The environment to use.

Returns

A self reference.

## Instance Properties

code » args_ : `!Array.<string>`
code » env_ : `Object.<string, string>`
code » exe_ : `string`
code » port_ : `number`
code » stdio_ : `(string|!Array)`