module selenium-webdriver/chrome

Defines a WebDriver client for the Chrome web browser. Before using this module, you must download the latest ChromeDriver release and ensure it can be found on your system PATH.

There are three primary classes exported by this module:

  1. ServiceBuilder: configures the remote.DriverService that manages the ChromeDriver child process.

  2. Options: defines configuration options for each new Chrome session, such as which proxy to use, what extensions to install, or what command-line switches to use when starting the browser.

  3. Driver: the WebDriver client; each new instance will control a unique browser session with a clean user profile (unless otherwise configured through the Options class).

By default, every Chrome session will use a single driver service, which is started the first time a Driver instance is created and terminated when this process exits. The default service will inherit its environment from the current process and direct all output to /dev/null. You may obtain a handle to this default service using getDefaultService() and change its configuration with setDefaultService().

You may also create a Driver with its own driver service. This is useful if you need to capture the server's log output for a specific session:

var chrome = require('selenium-webdriver/chrome');

var service = new chrome.ServiceBuilder()
    .loggingTo('/my/log/file.txt')
    .enableVerboseLogging()
    .build();

var options = new chrome.Options();
// configure browser options ...

var driver = new chrome.Driver(options, service);

Users should only instantiate the Driver class directly when they need a custom driver service configuration (as shown above). For normal operation, users should start Chrome using the selenium-webdriver.Builder.

Functions

createDriver(opt_options, opt_service, opt_flow)code »

deprecated

Creates a new ChromeDriver session.

Deprecated: Use new Driver().

Parameters
opt_options?(Capabilities|Options)=

The session options.

opt_service?DriverService=

The session to use; will use the default service by default.

opt_flow?webdriver.promise.ControlFlow=

The control flow to use, or null to use the currently active flow.

Returns
webdriver.WebDriver

A new WebDriver instance.


getDefaultService()code »

Returns the default ChromeDriver service. If such a service has not been configured, one will be constructed using the default configuration for a ChromeDriver executable found on the system PATH.

Returns
DriverService

The default ChromeDriver service.


setDefaultService(service)code »

Sets the default service to use for new ChromeDriver instances.

Parameters
serviceDriverService

The service to use.

Throws
Error

If the default service is currently running.

Types

Driver

Creates a new WebDriver client for Chrome.

Options

Class for managing ChromeDriver specific options.

ServiceBuilder

Creates remote.DriverService instances that manage a ChromeDriver server in a child process.