Class Builder
code »Creates new WebDriver
instances. The environment
variables listed below may be used to override a builder's configuration,
allowing quick runtime changes.
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).SELENIUM_BROWSER
: defines the target browser in the formbrowser[:version][:platform]
.
Suppose you had mytest.js that created WebDriver with
var driver = new webdriver.Builder().build();
.
This test could be made to use Firefox on the local machine by running with
SELENIUM_BROWSER=firefox node mytest.js
.
Alternatively, you could request Chrome 36 on Linux from a remote
server with SELENIUM_BROWSER=chrome:36:LINUX
SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub
node mytest.js
.
Constructor
Instance Methods
code »build ( ) ⇒ !webdriver.WebDriver
Creates a new WebDriver client based on this builder's current
configuration.
!webdriver.WebDriver
Returns |
---|
|
Throws |
|
code »forBrowser ( name, opt_version, opt_platform ) ⇒ !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 SELENIUM_BROWSER
environment variable. If set, this environment variable should be of the
form browser[:[version][:platform]]
.
!Builder
#withCapabilities
after this function will
overwrite these settings.
SELENIUM_BROWSER
environment variable. If set, this environment variable should be of the
form browser[:[version][:platform]]
.Parameters |
---|
|
Returns |
|
Returns the base set of capabilities this instance is currently configured
to use.
Returns |
---|
|
code »getServerUrl ( ) ⇒ string
string
Returns |
---|
|
code »setAlertBehavior ( behavior ) ⇒ !Builder
Sets the default action to take with an unexpected alert before returning
an error.
!Builder
Parameters |
---|
|
Returns |
|
code »setChromeOptions ( options ) ⇒ !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.
!Builder
#setLoggingPrefs
and #setProxy
,
respectively.Parameters |
---|
|
Returns |
|
code »setControlFlow ( flow ) ⇒ !Builder
Sets the control flow that created drivers should execute actions in. If
the flow is never set, or is set to null
, it will use the active
flow at the time #build()
is called.
!Builder
null
, it will use the active
flow at the time #build()
is called.Parameters |
---|
|
Returns |
|
code »setEnableNativeEvents ( enabled ) ⇒ !Builder
Sets whether native events should be used.
!Builder
Parameters |
---|
|
Returns |
|
code »setFirefoxOptions ( options ) ⇒ !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.
!Builder
#setLoggingPrefs
and #setProxy
,
respectively.Parameters |
---|
|
Returns |
|
code »setLoggingPrefs ( prefs ) ⇒ !Builder
Sets the logging preferences for the created session. Preferences may be
changed by repeated calls, or by calling #withCapabilities
.
!Builder
#withCapabilities
.Parameters |
---|
|
Returns |
|
Sets the proxy configuration to use for WebDriver clients created by this
builder. Any calls to #withCapabilities
after this function will
overwrite these settings.
#withCapabilities
after this function will
overwrite these settings.Parameters |
---|
|
Returns |
|
code »setScrollBehavior ( behavior ) ⇒ !Builder
Sets how elements should be scrolled into view for interaction.
!Builder
Parameters |
---|
|
Returns |
|
code »usingServer ( url ) ⇒ !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.
!Builder
SELENIUM_REMOTE_URL
environment variable.Parameters |
---|
|
Returns |
|
code »withCapabilities ( capabilities ) ⇒ !Builder
Sets the desired capabilities when requesting a new session. This will
overwrite any previously set capabilities.
!Builder
Parameters |
---|
|
Returns |
|
Instance Properties
code »chromeOptions_ : chrome.Options
chrome.Options
code »firefoxOptions_ : firefox.Options
firefox.Options