Methods
build() → (non-null) {ThenableWebDriver}
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 instance. The promise will be rejected if the remote end fails to create a new session.
If the current configuration is invalid.
- Type
- Error
A new WebDriver instance.
- Type:
- ThenableWebDriver
disableEnvironmentOverrides() → (non-null) {Builder}
Configures this builder to ignore any environment variable overrides and to only use the configuration specified through this instance's API.
A self reference.
- Type:
- Builder
forBrowser(name, opt_versionopt, opt_platformopt) → (non-null) {Builder}
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 browser[:[version][:platform]]
.
Name | Type | Attributes | Description |
---|---|---|---|
name | string | | The name of the target browser; common defaults are available on the webdriver.Browser enum. | |
opt_version | string | <optional> | A desired version; may be omitted if any version should be used. |
opt_platform | string | | <optional> | The desired platform; may be omitted if any platform may be used. |
A self reference.
- Type:
- Builder
getCapabilities() → (non-null) {Capabilities}
Returns the base set of capabilities this instance is currently configured to use.
The current capabilities for this builder.
- Type:
- Capabilities
getChromeOptions() → {chrome.Options}
the Chrome specific options currently configured for this builder.
- Type:
- chrome.
Options
getFirefoxOptions() → {firefox.Options}
the Firefox specific options currently configured for this instance.
- Type:
- firefox.
Options
getHttpAgent() → {http.Agent}
The http agent used for each request
- Type:
- http.
Agent
getSafariOptions() → {safari.Options}
the Safari specific options currently configured for this instance.
- Type:
- safari.
Options
getServerUrl() → {string}
The URL of the WebDriver server this instance is configured to use.
- Type:
- string
getWebDriverProxy() → (nullable) {string}
The URL of the proxy server to use for the WebDriver's HTTP connections, or null
if not set.
- Type:
- string
setAlertBehavior(behaviornullable) → (non-null) {Builder}
Sets the default action to take with an unexpected alert before returning an error.
Name | Type | Attributes | Description |
---|---|---|---|
behavior | capabilities. | <nullable> | The desired behavior. |
- See
- capabilities.Capabilities#setAlertBehavior
A self reference.
- Type:
- Builder
setCapability(key, value) → (non-null) {Builder}
Sets the desired capability when requesting a new session. If there is already a capability named key, its value will be overwritten with value. This is a convenience wrapper around builder.getCapabilities().set(key, value) to support Builder method chaining.
Name | Type | Description |
---|---|---|
key | string | The capability key. |
value | * | The capability value. |
A self reference.
- Type:
- Builder
setChromeOptions(optionsnon-null) → (non-null) {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.
Name | Type | Description |
---|---|---|
options | chrome. | The ChromeDriver options to use. |
A self reference.
- Type:
- Builder
setChromeService(service) → (non-null) {Builder}
Sets the service builder to use for managing the chromedriver child process when creating new Chrome sessions.
Name | Type | Description |
---|---|---|
service | chrome. | the service to use. |
A self reference.
- Type:
- Builder
setEdgeOptions(optionsnon-null) → (non-null) {Builder}
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.
Name | Type | Description |
---|---|---|
options | edge. | The MicrosoftEdgeDriver options to use. |
A self reference.
- Type:
- Builder
setEdgeService(service) → (non-null) {Builder}
Sets the edge.ServiceBuilder to use to manage the MicrosoftEdgeDriver child process when creating sessions locally.
Name | Type | Description |
---|---|---|
service | edge. | the service to use. |
a self reference.
- Type:
- Builder
setFirefoxOptions(optionsnon-null) → (non-null) {Builder}
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.
Name | Type | Description |
---|---|---|
options | firefox. | The FirefoxDriver options to use. |
A self reference.
- Type:
- Builder
setFirefoxService(service) → (non-null) {Builder}
Sets the firefox.ServiceBuilder to use to manage the geckodriver child process when creating Firefox sessions locally.
Name | Type | Description |
---|---|---|
service | firefox. | the service to use. |
a self reference.
- Type:
- Builder
setIeOptions(optionsnon-null) → (non-null) {Builder}
Set Internet Explorer specific options for drivers created by this builder. Any proxy settings defined on the given options will take precedence over those set through #setProxy.
Name | Type | Description |
---|---|---|
options | ie. | The IEDriver options to use. |
A self reference.
- Type:
- Builder
setIeService(service) → (non-null) {Builder}
Sets the ie.ServiceBuilder to use to manage the geckodriver child process when creating IE sessions locally.
Name | Type | Description |
---|---|---|
service | ie. | the service to use. |
a self reference.
- Type:
- Builder
setLoggingPrefs(prefs) → (non-null) {Builder}
Sets the logging preferences for the created session. Preferences may be changed by repeated calls, or by calling #withCapabilities.
Name | Type | Description |
---|---|---|
prefs |
A self reference.
- Type:
- Builder
setProxy(config) → (non-null) {Builder}
Sets the proxy configuration for the target browser. Any calls to #withCapabilities after this function will overwrite these settings.
Name | Type | Description |
---|---|---|
config |
A self reference.
- Type:
- Builder
setSafariOptions(optionsnon-null) → (non-null) {Builder}
Sets Safari specific options for drivers created by this builder. Any logging settings defined on the given options will take precedence over those set through #setLoggingPrefs.
Name | Type | Description |
---|---|---|
options | safari. | The Safari options to use. |
A self reference.
- Type:
- Builder
usingHttpAgent(agent) → (non-null) {Builder}
Sets the http agent to use for each request. If this method is not called, the Builder will use http.globalAgent by default.
Name | Type | Description |
---|---|---|
agent | http. | The agent to use for each request. |
A self reference.
- Type:
- Builder
usingServer(url) → (non-null) {Builder}
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 SELENIUM_REMOTE_URL
environment variable.
Name | Type | Description |
---|---|---|
url | string | The URL of a remote server to use. |
A self reference.
- Type:
- Builder
usingWebDriverProxy(proxy) → (non-null) {Builder}
Sets the URL of the proxy to use for the WebDriver's HTTP connections. If this method is never called, the Builder will create a connection without a proxy.
Name | Type | Description |
---|---|---|
proxy | string | The URL of a proxy to use. |
A self reference.
- Type:
- Builder
withCapabilities(capabilitiesnon-null) → (non-null) {Builder}
Recommended way is to use set*Options where * is the browser(eg setChromeOptions)
Sets the desired capabilities when requesting a new session. This will overwrite any previously set capabilities.
Name | Type | Description |
---|---|---|
capabilities | Object | | The desired capabilities for a new session. |
A self reference.
- Type:
- Builder