Creates a new WebDriver client based on this builder's current configuration.
This method will return a ThenableWebDriver instance, allowing
users to issue commands directly without calling then()
. The returned
thenable wraps a promise that will resolve to a concrete
webdriver.WebDriver WebDriver instance. The promise will be
rejected if the remote end fails to create a new session.
A new WebDriver instance.
If the current configuration is invalid.
Configures the target browser for clients created by this instance. Any calls to #withCapabilities after this function will overwrite these settings.
You may also define the target browser using the {@code SELENIUM_BROWSER} environment variable. If set, this environment variable should be of the form {@code browser[:[version][:platform]]}.
The name of the target browser; common defaults are available on the Browser enum.
Optional
opt_version: stringA desired version; may be omitted if any version should be used.
Optional
opt_platform: stringThe desired platform; may be omitted if any version may be used.
A self reference.
Returns the base set of capabilities this instance is currently configured to use.
The current capabilities for this builder.
Sets Chrome-specific options for drivers created by this builder. Any logging or proxy settings defined on the given options will take precedence over those set through #setLoggingPrefs and #setProxy, respectively.
The ChromeDriver options to use.
A self reference.
Sets the service builder to use for managing the chromedriver child process when creating new Chrome sessions.
the service to use.
A self reference.
Set options specific to Microsoft's Edge browser for drivers created by this builder. Any proxy settings defined on the given options will take precedence over those set through #setProxy.
The MicrosoftEdgeDriver options to use.
A self reference.
Sets the edge.ServiceBuilder to use to manage the MicrosoftEdgeDriver child process when creating sessions locally.
the service to use.
a self reference.
Sets Firefox-specific options for drivers created by this builder. Any logging or proxy settings defined on the given options will take precedence over those set through #setLoggingPrefs and #setProxy, respectively.
The FirefoxDriver options to use.
A self reference.
Sets the firefox.ServiceBuilder to use to manage the geckodriver child process when creating Firefox sessions locally.
the service to use.
a self reference.
Sets the ie.ServiceBuilder to use to manage the geckodriver child process when creating IE sessions locally.
the service to use.
a self reference.
Sets the logging preferences for the created session. Preferences may be changed by repeated calls, or by calling #withCapabilities.
The desired logging preferences.
A self reference.
Sets the proxy configuration to use for WebDriver clients created by this builder. Any calls to #withCapabilities after this function will overwrite these settings.
The configuration to use.
A self reference.
Sets the URL of a remote WebDriver server to use. Once a remote URL has been specified, the builder direct all new clients to that server. If this method is never called, the Builder will attempt to create all clients locally.
As an alternative to this method, you may also set the {@code SELENIUM_REMOTE_URL} environment variable.
The URL of a remote server to use.
A self reference.
Sets the desired capabilities when requesting a new session. This will overwrite any previously set capabilities.
The desired capabilities for a new session.
A self reference.
Generated using TypeDoc
Creates new WebDriver instances. The environment variables listed below may be used to override a builder's configuration, allowing quick runtime changes.
{@code SELENIUM_BROWSER}: defines the target browser in the form {@code browser[:version][:platform]}.
{@code SELENIUM_REMOTE_URL}: defines the remote URL for all builder instances. This environment variable should be set to a fully qualified URL for a WebDriver server (e.g. http://localhost:4444/wd/hub). This option always takes precedence over {@code SELENIUM_SERVER_JAR}.
{@code SELENIUM_SERVER_JAR}: defines the path to the
standalone Selenium server jar to use. The server will be started the first time a WebDriver instance and be killed when the process exits.Suppose you had mytest.js that created WebDriver with
This test could be made to use Firefox on the local machine by running with
SELENIUM_BROWSER=firefox node mytest.js
. Rather than change the code to target Google Chrome on a remote machine, you can simply set theSELENIUM_BROWSER
andSELENIUM_REMOTE_URL
environment variables:You could also use a local copy of the standalone Selenium server: