<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>webdriver.WebDriver</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Class webdriver.WebDriver</h1><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l74">code »</a></header><section><p>Creates a new WebDriver client, which provides control over a browser. | |
Every WebDriver command returns a <code >webdriver.promise.Promise</code> that | |
represents the result of that command. Callbacks may be registered on this | |
object to manipulate the command result or catch an expected error. Any | |
commands scheduled with a callback are considered sub-commands and will | |
execute before the next command in the current frame. For example: | |
<pre><code> | |
var message = []; | |
driver.call(message.push, message, 'a').then(function() { | |
driver.call(message.push, message, 'b'); | |
}); | |
driver.call(message.push, message, 'c'); | |
driver.call(function() { | |
alert('message is abc? ' + (message.join('') == 'abc')); | |
}); | |
</code></pre><h2>Constructor</h2><div class="ctor wrap-details public"><div><div class="ctor"><span class="member">webdriver.WebDriver <span class="args">( session, executor, opt_flow )</span></span></div><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>session: <code class="type">!(<a href="class_webdriver_Session.html">webdriver.Session</a>|<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>)</code><dd>Either a | |
known session or a promise that will be resolved to a session.<dt>executor: <code class="type">!<a href="interface_webdriver_CommandExecutor.html">webdriver.CommandExecutor</a></code><dd>The executor to use when | |
sending commands to the browser.<dt>opt_flow: <code class="type"><a href="class_webdriver_promise_ControlFlow.html">webdriver.promise.ControlFlow</a>=</code><dd>The flow to | |
schedule commands through. Defaults to the active flow object.</dl></table></div></div></div></section><section><h2>Classes</h2><div class="type-summary"><table><tbody><tr><td><dl><dt><a href="class_webdriver_WebDriver_Logs.html">webdriver.WebDriver.Logs</a><dd>Interface for managing WebDriver log records.<dt><a href="class_webdriver_WebDriver_Navigation.html">webdriver.WebDriver.Navigation</a><dd>Interface for navigating back and forth in the browser history.<dt><a href="class_webdriver_WebDriver_Options.html">webdriver.WebDriver.Options</a><dd>Provides methods for managing browser and driver state.<dt><a href="class_webdriver_WebDriver_TargetLocator.html">webdriver.WebDriver.TargetLocator</a><dd>An interface for changing the focus of the driver to another frame or window.<dt><a href="class_webdriver_WebDriver_Timeouts.html">webdriver.WebDriver.Timeouts</a><dd>An interface for managing timeout behavior for WebDriver instances.<dt><a href="class_webdriver_WebDriver_Window.html">webdriver.WebDriver.Window</a><dd>An interface for managing the current window.</dl></table></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/lib/webdriver/webdriver.js.src.html#l357">code »</a><span class="member"><a name="actions">actions</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code></span></div><p>Creates a new action sequence using this driver. The sequence will not be | |
scheduled for execution until <code class="type"><a href="class_webdriver_ActionSequence.html#perform">webdriver.ActionSequence#perform</a></code> is | |
called. Example: | |
<pre><code> | |
driver.actions(). | |
mouseDown(element1). | |
mouseMove(element2). | |
mouseUp(). | |
perform(); | |
</code></pre></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A new action sequence for this instance.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l514">code »</a><code class="type"><T></code> <span class="member"><a name="call">call</a> <span class="args">( fn, opt_scope, var_args )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<T></code></span></div><p>Schedules a command to execute a custom function.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>fn: <code class="type">function(...): (T|<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<T>)</code><dd>The function to | |
execute.<dt>opt_scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd>The object in whose scope to execute the function.<dt>var_args: <code class="type">...*</code><dd>Any arguments to pass to the function.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved' | |
with the function's result.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l602">code »</a><span class="member"><a name="close">close</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<void></code></span></div><p>Schedules a command to close the current window.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will be resolved | |
when this command has completed.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l247">code »</a><span class="member"><a name="controlFlow">controlFlow</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_ControlFlow.html">webdriver.promise.ControlFlow</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The control flow used by this | |
instance.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l492">code »</a><code class="type"><T></code> <span class="member"><a name="executeAsyncScript">executeAsyncScript</a> <span class="args">( script, var_args )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<T></code></span></div><p>Schedules a command to execute asynchronous JavaScript in the context of the | |
currently selected frame or window. The script fragment will be executed as | |
the body of an anonymous function. If the script is provided as a function | |
object, that function will be converted to a string for injection into the | |
target window. | |
Any arguments provided in addition to the script will be included as script | |
arguments and may be referenced using the <code >arguments</code> object. | |
Arguments may be a boolean, number, string, or <code >webdriver.WebElement</code>. | |
Arrays and objects may also be used as script arguments as long as each item | |
adheres to the types previously mentioned. | |
Unlike executing synchronous JavaScript with | |
<code >webdriver.WebDriver.prototype.executeScript</code>, scripts executed with | |
this function must explicitly signal they are finished by invoking the | |
provided callback. This callback will always be injected into the | |
executed function as the last argument, and thus may be referenced with | |
<code >arguments[arguments.length - 1]</code>. The following steps will be taken | |
for resolving this functions return value against the first argument to the | |
script's callback function: | |
<ul> | |
<li>For a HTML element, the value will resolve to a | |
<code >webdriver.WebElement</code></li> | |
<li>Null and undefined return values will resolve to null</li> | |
<li>Booleans, numbers, and strings will resolve as is</li> | |
<li>Functions will resolve to their string representation</li> | |
<li>For arrays and objects, each member item will be converted according to | |
the rules above</li> | |
</ul> | |
Example #1: Performing a sleep that is synchronized with the currently | |
selected window: | |
<code><pre> | |
var start = new Date().getTime(); | |
driver.executeAsyncScript( | |
'window.setTimeout(arguments[arguments.length - 1], 500);'). | |
then(function() { | |
console.log('Elapsed time: ' + (new Date().getTime() - start) + ' ms'); | |
}); | |
</pre></code> | |
Example #2: Synchronizing a test with an AJAX application: | |
<code><pre> | |
var button = driver.findElement(By.id('compose-button')); | |
button.click(); | |
driver.executeAsyncScript( | |
'var callback = arguments[arguments.length - 1];' + | |
'mailClient.getComposeWindowWidget().onload(callback);'); | |
driver.switchTo().frame('composeWidget'); | |
driver.findElement(By.id('to')).sendKEys('dog@example.com'); | |
</pre></code> | |
Example #3: Injecting a XMLHttpRequest and waiting for the result. In this | |
example, the inject script is specified with a function literal. When using | |
this format, the function is converted to a string for injection, so it | |
should not reference any symbols not defined in the scope of the page under | |
test. | |
<code><pre> | |
driver.executeAsyncScript(function() { | |
var callback = arguments[arguments.length - 1]; | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", "/resource/data.json", true); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == 4) { | |
callback(xhr.resposneText); | |
} | |
} | |
xhr.send(''); | |
}).then(function(str) { | |
console.log(JSON.parse(str)['food']); | |
}); | |
</pre></code></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>script: <code class="type">!(<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/Function">Function</a>)</code><dd>The script to execute.<dt>var_args: <code class="type">...*</code><dd>The arguments to pass to the script.</dl><tr><th>Returns<tr><td><dl>A promise that will resolve to the | |
scripts return value.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l400">code »</a><code class="type"><T></code> <span class="member"><a name="executeScript">executeScript</a> <span class="args">( script, var_args )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<T></code></span></div><p>Schedules a command to execute JavaScript in the context of the currently | |
selected frame or window. The script fragment will be executed as the body | |
of an anonymous function. If the script is provided as a function object, | |
that function will be converted to a string for injection into the target | |
window. | |
Any arguments provided in addition to the script will be included as script | |
arguments and may be referenced using the <code >arguments</code> object. | |
Arguments may be a boolean, number, string, or <code >webdriver.WebElement</code>. | |
Arrays and objects may also be used as script arguments as long as each item | |
adheres to the types previously mentioned. | |
The script may refer to any variables accessible from the current window. | |
Furthermore, the script will execute in the window's context, thus | |
<code >document</code> may be used to refer to the current document. Any local | |
variables will not be available once the script has finished executing, | |
though global variables will persist. | |
If the script has a return value (i.e. if the script contains a return | |
statement), then the following steps will be taken for resolving this | |
functions return value: | |
<ul> | |
<li>For a HTML element, the value will resolve to a | |
<code >webdriver.WebElement</code></li> | |
<li>Null and undefined return values will resolve to null</li> | |
<li>Booleans, numbers, and strings will resolve as is</li> | |
<li>Functions will resolve to their string representation</li> | |
<li>For arrays and objects, each member item will be converted according to | |
the rules above</li> | |
</ul></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>script: <code class="type">!(<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/Function">Function</a>)</code><dd>The script to execute.<dt>var_args: <code class="type">...*</code><dd>The arguments to pass to the script.</dl><tr><th>Returns<tr><td><dl>A promise that will resolve to the | |
scripts return value.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l754">code »</a><span class="member"><a name="findDomElement_">findDomElement_</a> <span class="args">( element )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>></code></span></div><p>Locates a DOM element so that commands may be issued against it using the | |
<code class="type"><a href="class_webdriver_WebElement.html">webdriver.WebElement</a></code> class. This is accomplished by storing a | |
reference to the element in an object on the element's ownerDocument. | |
<code class="type"><a class="unresolved-link">#executeScript</a></code> will then be used to create a WebElement from this | |
reference. This requires this driver to currently be focused on the | |
ownerDocument's window+frame.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>element: <code class="type">!<a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-745549614">Element</a></code><dd>The element to locate.</dl><tr><th>Returns<tr><td><dl>A promise that | |
will be fulfilled with the located element, or null if the element | |
could not be found.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l691">code »</a><span class="member"><a name="findElement">findElement</a> <span class="args">( locator )</span> ⇒ <code class="type">!<a href="class_webdriver_WebElement.html">webdriver.WebElement</a></code></span></div><p>Schedule a command to find an element on the page. If the element cannot be | |
found, a <code class="type"><a href="enum_bot_ErrorCode.html#bot.ErrorCode.NO_SUCH_ELEMENT">bot.ErrorCode.NO_SUCH_ELEMENT</a></code> result will be returned | |
by the driver. Unlike other commands, this error cannot be suppressed. In | |
other words, scheduling a command to find an element doubles as an assert | |
that the element is present on the page. To test whether an element is | |
present on the page, use <code class="type"><a class="unresolved-link">#isElementPresent</a></code> instead. | |
<p>The search criteria for an element may be defined using one of the | |
factories in the <code class="type"><a href="namespace_webdriver_By.html">webdriver.By</a></code> namespace, or as a short-hand | |
<code class="type"><a href="namespace_webdriver_By.html#webdriver.By.Hash">webdriver.By.Hash</a></code> object. For example, the following two statements | |
are equivalent: | |
<code><pre> | |
var e1 = driver.findElement(By.id('foo')); | |
var e2 = driver.findElement({id:'foo'}); | |
</pre></code> | |
<p>You may also provide a custom locator function, which takes as input | |
this WebDriver instance and returns a <code class="type"><a href="class_webdriver_WebElement.html">webdriver.WebElement</a></code>, or a | |
promise that will resolve to a WebElement. For example, to find the first | |
visible link on a page, you could write: | |
<code><pre> | |
var link = driver.findElement(firstVisibleLink); | |
function firstVisibleLink(driver) { | |
var links = driver.findElements(By.tagName('a')); | |
return webdriver.promise.filter(links, function(link) { | |
return links.isDisplayed(); | |
}).then(function(visibleLinks) { | |
return visibleLinks[0]; | |
}); | |
} | |
</pre></code> | |
<p>When running in the browser, a WebDriver cannot manipulate DOM elements | |
directly; it may do so only through a <code class="type"><a href="class_webdriver_WebElement.html">webdriver.WebElement</a></code> reference. | |
This function may be used to generate a WebElement from a DOM element. A | |
reference to the DOM element will be stored in a known location and this | |
driver will attempt to retrieve it through <code class="type"><a class="unresolved-link">#executeScript</a></code>. If the | |
element cannot be found (eg, it belongs to a different document than the | |
one this instance is currently focused on), a | |
<code class="type"><a href="enum_bot_ErrorCode.html#bot.ErrorCode.NO_SUCH_ELEMENT">bot.ErrorCode.NO_SUCH_ELEMENT</a></code> error will be returned.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>locator: <code class="type">!(<a href="class_webdriver_Locator.html">webdriver.Locator</a>|<a href="namespace_webdriver_By.html#webdriver.By.Hash">webdriver.By.Hash</a>|<a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-745549614">Element</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a>)</code><dd>The | |
locator to use.</dl><tr><th>Returns<tr><td><dl>A WebElement that can be used to issue | |
commands against the located element. If the element is not found, the | |
element will be invalidated and all scheduled commands aborted.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l726">code »</a><span class="member"><a name="findElementInternal_">findElementInternal_</a> <span class="args">( locatorFn, context )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>locatorFn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The locator function to use.<dt>context: <code class="type">!(<a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a>|<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>)</code><dd>The search | |
context.</dl><tr><th>Returns<tr><td><dl>A | |
promise that will resolve to a list of WebElements.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l818">code »</a><span class="member"><a name="findElements">findElements</a> <span class="args">( locator )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Schedule a command to search for multiple elements on the page.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>locator: <code class="type">!(<a href="class_webdriver_Locator.html">webdriver.Locator</a>|<a href="namespace_webdriver_By.html#webdriver.By.Hash">webdriver.By.Hash</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a>)</code><dd>The locator | |
strategy to use when searching for the element.</dl><tr><th>Returns<tr><td><dl>A | |
promise that will resolve to an array of WebElements.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l839">code »</a><span class="member"><a name="findElementsInternal_">findElementsInternal_</a> <span class="args">( locatorFn, context )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>locatorFn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The locator function to use.<dt>context: <code class="type">!(<a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a>|<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>)</code><dd>The search | |
context.</dl><tr><th>Returns<tr><td><dl>A | |
promise that will resolve to an array of WebElements.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l614">code »</a><span class="member"><a name="get">get</a> <span class="args">( url )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<void></code></span></div><p>Schedules a command to navigate to the given URL.</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 fully qualified URL to open.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved | |
when the document has finished loading.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l575">code »</a><span class="member"><a name="getAllWindowHandles">getAllWindowHandles</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Schedules a command to retrieve the current list of available window handles.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will | |
be resolved with an array of window handles.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l318">code »</a><span class="member"><a name="getCapabilities">getCapabilities</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise | |
that will resolve with the this instance's capabilities.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l624">code »</a><span class="member"><a name="getCurrentUrl">getCurrentUrl</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code></span></div><p>Schedules a command to retrieve the URL of the current page.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will be | |
resolved with the current URL.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l590">code »</a><span class="member"><a name="getPageSource">getPageSource</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code></span></div><p>Schedules a command to retrieve the current page's source. The page source | |
returned is a representation of the underlying DOM: do not expect it to be | |
formatted or escaped in the same way as the response sent from the web | |
server.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will be | |
resolved with the current page source.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l309">code »</a><span class="member"><a name="getSession">getSession</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise for this | |
client's session.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l636">code »</a><span class="member"><a name="getTitle">getTitle</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code></span></div><p>Schedules a command to retrieve the current page's title.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will be | |
resolved with the current page's title.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l563">code »</a><span class="member"><a name="getWindowHandle">getWindowHandle</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code></span></div><p>Schedules a command to retrieve they current window handle.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will be | |
resolved with the current window handle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l798">code »</a><span class="member"><a name="isElementPresent">isElementPresent</a> <span class="args">( locatorOrElement )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>></code></span></div><p>Schedules a command to test if an element is present on the page. | |
<p>If given a DOM element, this function will check if it belongs to the | |
document the driver is currently focused on. Otherwise, the function will | |
test if at least one element can be found with the given search criteria.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>locatorOrElement: <code class="type">!(<a href="class_webdriver_Locator.html">webdriver.Locator</a>|<a href="namespace_webdriver_By.html#webdriver.By.Hash">webdriver.By.Hash</a>|<a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-745549614">Element</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a>)</code><dd>The locator to use, or the actual | |
DOM element to be located by the server.</dl><tr><th>Returns<tr><td><dl>A promise that will resolve | |
with whether the element is present on the page.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l880">code »</a><span class="member"><a name="manage">manage</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_WebDriver_Options.html">webdriver.WebDriver.Options</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The options interface for this | |
instance.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l889">code »</a><span class="member"><a name="navigate">navigate</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_WebDriver_Navigation.html">webdriver.WebDriver.Navigation</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The navigation interface for this | |
instance.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l332">code »</a><span class="member"><a name="quit">quit</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<void></code></span></div><p>Schedules a command to quit the current session. After calling quit, this | |
instance will be invalidated and may no longer be used to issue commands | |
against the browser.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will be resolved | |
when the command has completed.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l261">code »</a><code class="type"><T></code> <span class="member"><a name="schedule">schedule</a> <span class="args">( command, description )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<T></code></span></div><p>Schedules a <code >webdriver.Command</code> to be executed by this driver's | |
<code >webdriver.CommandExecutor</code>.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>command: <code class="type">!<a href="class_webdriver_Command.html">webdriver.Command</a></code><dd>The command to schedule.<dt>description: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A description of the command for debugging.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved | |
with the command result.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l553">code »</a><span class="member"><a name="sleep">sleep</a> <span class="args">( ms )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<void></code></span></div><p>Schedules a command to make the driver sleep for the given amount of time.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>ms: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The amount of time, in milliseconds, to sleep.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved | |
when the sleep has finished.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l898">code »</a><span class="member"><a name="switchTo">switchTo</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_WebDriver_TargetLocator.html">webdriver.WebDriver.TargetLocator</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The target locator interface for | |
this instance.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l870">code »</a><span class="member"><a name="takeScreenshot">takeScreenshot</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code></span></div><p>Schedule a command to take a screenshot. The driver makes a best effort to | |
return a screenshot of the following, in order of preference: | |
<ol> | |
<li>Entire page | |
<li>Current window | |
<li>Visible portion of the current frame | |
<li>The screenshot of the entire display containing the browser | |
</ol></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A promise that will be | |
resolved to the screenshot as a base-64 encoded PNG.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l542">code »</a><span class="member"><a name="wait">wait</a> <span class="args">( fn, timeout, opt_message )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Schedules a command to wait for a condition to hold, as defined by some | |
user supplied function. If any errors occur while evaluating the wait, they | |
will be allowed to propagate. | |
<p>In the event a condition returns a <code class="type"><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code>, the | |
polling loop will wait for it to be resolved and use the resolved value for | |
evaluating whether the condition has been satisfied. The resolution time for | |
a promise is factored into whether a wait has timed out.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>fn: <code class="type">function(): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd>The function to evaluate as a wait condition.<dt>timeout: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>How long to wait for the condition to be true.<dt>opt_message: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>An optional message to use if the wait times | |
out.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved when the | |
wait condition has been satisfied.</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/lib/webdriver/webdriver.js.src.html#l80">code »</a><span class="member"><a name="executor_">executor_</a> : <code class="type">!<a href="interface_webdriver_CommandExecutor.html">webdriver.CommandExecutor</a></code></span></div></summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l83">code »</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/lib/webdriver/webdriver.js.src.html#l77">code »</a><span class="member"><a name="session_">session_</a> : <code class="type">!(<a href="class_webdriver_Session.html">webdriver.Session</a>|<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>)</code></span></div></summary></details></div></div></section><section id="static-functions"><h2>Static Functions</h2><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l130">code »</a><span class="member"><a name="webdriver.WebDriver.acquireSession_">webdriver.WebDriver.acquireSession_</a> <span class="args">( executor, command, description )</span> ⇒ <code class="type">!<a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a></code></span></div><p>Sends a command to the server that is expected to return the details for a | |
<code class="type"><a href="class_webdriver_Session.html">webdriver.Session</a></code>. This may either be an existing session, or a | |
newly created one.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>executor: <code class="type">!<a href="interface_webdriver_CommandExecutor.html">webdriver.CommandExecutor</a></code><dd>Command executor to use when | |
querying for session details.<dt>command: <code class="type">!<a href="class_webdriver_Command.html">webdriver.Command</a></code><dd>The command to send to fetch the session | |
details.<dt>description: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A descriptive debug label for this action.</dl><tr><th>Returns<tr><td><dl>A new WebDriver client for the session.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l94">code »</a><span class="member"><a name="webdriver.WebDriver.attachToSession">webdriver.WebDriver.attachToSession</a> <span class="args">( executor, sessionId )</span> ⇒ <code class="type">!<a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a></code></span></div><p>Creates a new WebDriver client for an existing session.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>executor: <code class="type">!<a href="interface_webdriver_CommandExecutor.html">webdriver.CommandExecutor</a></code><dd>Command executor to use when | |
querying for session details.<dt>sessionId: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>ID of the session to attach to.</dl><tr><th>Returns<tr><td><dl>A new client for the specified session.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l110">code »</a><span class="member"><a name="webdriver.WebDriver.createSession">webdriver.WebDriver.createSession</a> <span class="args">( executor, desiredCapabilities )</span> ⇒ <code class="type">!<a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a></code></span></div><p>Creates a new WebDriver session.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>executor: <code class="type">!<a href="interface_webdriver_CommandExecutor.html">webdriver.CommandExecutor</a></code><dd>The executor to create the new | |
session with.<dt>desiredCapabilities: <code class="type">!<a href="class_webdriver_Capabilities.html">webdriver.Capabilities</a></code><dd>The desired | |
capabilities for the new session.</dl><tr><th>Returns<tr><td><dl>The driver for the newly created session.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l232">code »</a><span class="member"><a name="webdriver.WebDriver.executeCommand_">webdriver.WebDriver.executeCommand_</a> <span class="args">( executor, command )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Translates a command to its wire-protocol representation before passing it | |
to the given <code >executor</code> for execution.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>executor: <code class="type">!<a href="interface_webdriver_CommandExecutor.html">webdriver.CommandExecutor</a></code><dd>The executor to use.<dt>command: <code class="type">!<a href="class_webdriver_Command.html">webdriver.Command</a></code><dd>The command to execute.</dl><tr><th>Returns<tr><td><dl>A promise that will resolve with the | |
command response.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l206">code »</a><span class="member"><a name="webdriver.WebDriver.fromWireValue_">webdriver.WebDriver.fromWireValue_</a> <span class="args">( driver, value )</span> ⇒ <code class="type">*</code></span></div><p>Converts a value from its JSON representation according to the WebDriver wire | |
protocol. Any JSON object containing a | |
<code >webdriver.WebElement.ELEMENT_KEY</code> key will be decoded to a | |
<code >webdriver.WebElement</code> object. All other values will be passed through | |
as is.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>driver: <code class="type">!<a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a></code><dd>The driver instance to use as the | |
parent of any unwrapped <code >webdriver.WebElement</code> values.<dt>value: <code class="type">*</code><dd>The value to convert.</dl><tr><th>Returns<tr><td><dl>The converted value.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/webdriver.js.src.html#l162">code »</a><span class="member"><a name="webdriver.WebDriver.toWireValue_">webdriver.WebDriver.toWireValue_</a> <span class="args">( obj )</span> ⇒ <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Converts an object to its JSON representation in the WebDriver wire protocol. | |
When converting values of type object, the following steps will be taken: | |
<ol> | |
<li>if the object provides a "toWireValue" function, the return value will | |
be returned in its fully resolved state (e.g. this function may return | |
promise values)</li> | |
<li>if the object provides a "toJSON" function, the return value of this | |
function will be returned</li> | |
<li>otherwise, the value of each key will be recursively converted according | |
to the rules above.</li> | |
</ol></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>obj: <code class="type">*</code><dd>The object to convert.</dl><tr><th>Returns<tr><td><dl>A promise that will resolve to the | |
input value's JSON representation.</dl></table></div></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>No data</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>No data</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>No data</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> |