UNPKG

selenium-webdriver

Version:

The official WebDriver JavaScript bindings from the Selenium project

56 lines (50 loc) 17 kB
<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>Builder</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Class Builder</h1><a class="source" href="source/builder.js.src.html#l326">code &raquo;</a></header><section><p>Creates new <code class="type"><a href="class_webdriver_WebDriver.html">WebDriver</a></code> instances. The environment variables listed below may be used to override a builder's configuration, allowing quick runtime changes. <ul> <li><code >SELENIUM_REMOTE_URL</code>: 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). <li><code >SELENIUM_BROWSER</code>: defines the target browser in the form <code >browser[:version][:platform]</code>. </ul> <p>Suppose you had mytest.js that created WebDriver with <code >var driver = new webdriver.Builder().build();</code>. This test could be made to use Firefox on the local machine by running with <code >SELENIUM_BROWSER=firefox node mytest.js</code>. <p>Alternatively, you could request Chrome 36 on Linux from a remote server with <code > SELENIUM_BROWSER=chrome:36:LINUX SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub node mytest.js</code>.<h2>Constructor</h2><div class="ctor wrap-details public"><div><div class="ctor"><span class="member">Builder <span class="args">( )</span></span></div></div></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="instance-methods"><h2>Instance Methods</h2><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l260">code &raquo;</a><span class="member"><a name="build">build</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a></code></span></div><p>Creates a new WebDriver client based on this builder's current configuration.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A new WebDriver instance.</dl><tr><th>Throws<tr><td><dl><dt><code class="type"><a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error">Error</a></code><dd>If the current configuration is invalid.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l139">code &raquo;</a><span class="member"><a name="forBrowser">forBrowser</a> <span class="args">( name, opt_version, opt_platform )</span> &rArr; <code class="type">!Builder</code></span></div><p>Configures the target browser for clients created by this instance. Any calls to <code class="type"><a class="unresolved-link">#withCapabilities</a></code> after this function will overwrite these settings. <p>You may also define the target browser using the <code >SELENIUM_BROWSER</code> environment variable. If set, this environment variable should be of the form <code >browser[:[version][:platform]]</code>.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>name: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="enum_webdriver_Browser.html">webdriver.Browser</a>)</code><dd>The name of the target browser; common defaults are available on the <code class="type"><a href="enum_webdriver_Browser.html">webdriver.Browser</a></code> enum.<dt>opt_version: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>A desired version; may be omitted if any version should be used.<dt>opt_platform: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The desired platform; may be omitted if any version may be used.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l117">code &raquo;</a><span class="member"><a name="getCapabilities">getCapabilities</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_webdriver_Capabilities.html">webdriver.Capabilities</a></code></span></div><p>Returns the base set of capabilities this instance is currently configured to use.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The current capabilities for this builder.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l94">code &raquo;</a><span class="member"><a name="getServerUrl">getServerUrl</a> <span class="args">( )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The URL of the WebDriver server this instance is configured to use.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l203">code &raquo;</a><span class="member"><a name="setAlertBehavior">setAlertBehavior</a> <span class="args">( behavior )</span> &rArr; <code class="type">!Builder</code></span></div><p>Sets the default action to take with an unexpected alert before returning an error.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>behavior</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l218">code &raquo;</a><span class="member"><a name="setChromeOptions">setChromeOptions</a> <span class="args">( options )</span> &rArr; <code class="type">!Builder</code></span></div><p>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 <code class="type"><a class="unresolved-link">#setLoggingPrefs</a></code> and <code class="type"><a class="unresolved-link">#setProxy</a></code>, respectively.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>options: <code class="type">!chrome.Options</code><dd>The ChromeDriver options to use.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l247">code &raquo;</a><span class="member"><a name="setControlFlow">setControlFlow</a> <span class="args">( flow )</span> &rArr; <code class="type">!Builder</code></span></div><p>Sets the control flow that created drivers should execute actions in. If the flow is never set, or is set to <code >null</code>, it will use the active flow at the time <code class="type"><a class="unresolved-link">#build()</a></code> is called.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>flow: <code class="type"><a href="class_webdriver_promise_ControlFlow.html">webdriver.promise.ControlFlow</a></code><dd>The control flow to use, or <code >null</code> to</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l178">code &raquo;</a><span class="member"><a name="setEnableNativeEvents">setEnableNativeEvents</a> <span class="args">( enabled )</span> &rArr; <code class="type">!Builder</code></span></div><p>Sets whether native events should be used.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>enabled: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd>Whether to enable native events.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l233">code &raquo;</a><span class="member"><a name="setFirefoxOptions">setFirefoxOptions</a> <span class="args">( options )</span> &rArr; <code class="type">!Builder</code></span></div><p>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 <code class="type"><a class="unresolved-link">#setLoggingPrefs</a></code> and <code class="type"><a class="unresolved-link">#setProxy</a></code>, respectively.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>options: <code class="type">!firefox.Options</code><dd>The FirefoxDriver options to use.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l167">code &raquo;</a><span class="member"><a name="setLoggingPrefs">setLoggingPrefs</a> <span class="args">( prefs )</span> &rArr; <code class="type">!Builder</code></span></div><p>Sets the logging preferences for the created session. Preferences may be changed by repeated calls, or by calling <code class="type"><a class="unresolved-link">#withCapabilities</a></code>.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>prefs: <code class="type">!(<a href="class_webdriver_logging_Preferences.html">webdriver.logging.Preferences</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>.&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;)</code><dd>The desired logging preferences.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l154">code &raquo;</a><span class="member"><a name="setProxy">setProxy</a> <span class="args">( config )</span> &rArr; <code class="type">!Builder</code></span></div><p>Sets the proxy configuration to use for WebDriver clients created by this builder. Any calls to <code class="type"><a class="unresolved-link">#withCapabilities</a></code> after this function will overwrite these settings.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>config: <code class="type">!<a href="namespace_webdriver.html#webdriver.ProxyConfig">webdriver.ProxyConfig</a></code><dd>The configuration to use.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l190">code &raquo;</a><span class="member"><a name="setScrollBehavior">setScrollBehavior</a> <span class="args">( behavior )</span> &rArr; <code class="type">!Builder</code></span></div><p>Sets how elements should be scrolled into view for interaction.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>behavior: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The desired scroll behavior: either 0 to align with the top of the viewport or 1 to align with the bottom.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l84">code &raquo;</a><span class="member"><a name="usingServer">usingServer</a> <span class="args">( url )</span> &rArr; <code class="type">!Builder</code></span></div><p>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. <p>As an alternative to this method, you may also set the <code >SELENIUM_REMOTE_URL</code> environment variable.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>url: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URL of a remote server to use.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/builder.js.src.html#l106">code &raquo;</a><span class="member"><a name="withCapabilities">withCapabilities</a> <span class="args">( capabilities )</span> &rArr; <code class="type">!Builder</code></span></div><p>Sets the desired capabilities when requesting a new session. This will overwrite any previously set capabilities.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>capabilities: <code class="type">!(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>|<a href="class_webdriver_Capabilities.html">webdriver.Capabilities</a>)</code><dd>The desired capabilities for a new session.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div></section><section id="instance-properties"><h2>Instance Properties</h2><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/builder.js.src.html#l63">code &raquo;</a><span class="member"><a name="capabilities_">capabilities_</a> : <code class="type">!<a href="class_webdriver_Capabilities.html">webdriver.Capabilities</a></code></span></div></summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/builder.js.src.html#l66">code &raquo;</a><span class="member"><a name="chromeOptions_">chromeOptions_</a> : <code class="type">chrome.Options</code></span></div></summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/builder.js.src.html#l69">code &raquo;</a><span class="member"><a name="firefoxOptions_">firefoxOptions_</a> : <code class="type">firefox.Options</code></span></div></summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/builder.js.src.html#l57">code &raquo;</a><span class="member"><a name="flow_">flow_</a> : <code class="type"><a href="class_webdriver_promise_ControlFlow.html">webdriver.promise.ControlFlow</a></code></span></div></summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/builder.js.src.html#l60">code &raquo;</a><span class="member"><a name="url_">url_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>Loading</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>Loading</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>Loading</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script>