UNPKG

selenium-webdriver

Version:

The official WebDriver JavaScript bindings from the Selenium project

266 lines (262 loc) 36.3 kB
<!DOCTYPE html><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"><meta http-equiv="Content-Language" content="en"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>WebElementPromise</title><link href="dossier.css" rel="stylesheet" type="text/css"><header><div><form><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></header><main><article><div class="parentlink"><b>Module:</b> <a href="module_selenium-webdriver.html">selenium-webdriver</a></div><div class="codelink"><a href="source/index.js.src.html#l78">View Source</a></div><h1>class WebElementPromise</h1><pre class="inheritance"><a href="class_webdriver_Serializable.html">webdriver.Serializable</a>&lt;{ELEMENT: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}&gt; &#x2514; <a href="class_webdriver_WebElement.html">webdriver.WebElement</a> &#x2514; WebElementPromise</pre><dl><dt>Alias for <code><a href="class_webdriver_WebElementPromise.html">webdriver.WebElementPromise</a></code><dt>All implemented interfaces<dd><code>IThenable&lt;T&gt;</code><dd><code><a href="interface_webdriver_promise_Thenable.html">webdriver.promise.Thenable</a>&lt;<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>&gt;</code></dl><p>WebElementPromise is a promise that will be fulfilled with a WebElement. This serves as a forward proxy on WebElement, allowing calls to be scheduled without directly on this instance before the underlying WebElement has been fulfilled. In other words, the following two statements are equivalent:</p> <pre><code>driver.findElement({id: &#39;my-button&#39;}).click(); driver.findElement({id: &#39;my-button&#39;}).then(function(el) { return el.click(); }); </code></pre> <h3>new WebElementPromise(<wbr>driver, el)</h3><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>driver<code><a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a></code><dd><p>The parent WebDriver instance for this element.</p> <dt>el<code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>&gt;</code><dd><p>A promise that will resolve to the promised element.</p> </dl></div></div><h2>Instance Methods</h2><div id="cancel" class="function"><div><h3>cancel(<wbr>opt_reason)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2245">code »</a></span></h3><p>Cancels the computation of this promise&#39;s value, rejecting the promise in the process. This method is a no-op if the promise has already been resolved.</p> <p><b>Specified by: </b><a href="interface_webdriver_promise_Thenable.html#cancel">webdriver.promise.Thenable</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_reason<code>?(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="class_webdriver_promise_CancellationError.html">webdriver.promise.CancellationError</a>)=</code><dd><p>The reason this promise is being cancelled.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="clear" class="function"><div><h3>clear()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2171">code »</a></span></h3><p>Schedules a command to clear the <code>value</code> of this element. This command has no effect if the underlying DOM element is neither a text INPUT element nor a TEXTAREA element.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#clear">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>&gt;</code><dd><p>A promise that will be resolved when the element has been cleared.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="click" class="function"><div><h3>click()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1919">code »</a></span></h3><p>Schedules a command to click on this element.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#click">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>&gt;</code><dd><p>A promise that will be resolved when the click command has completed.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="findElement" class="function"><div><h3>findElement(<wbr>locator)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1859">code »</a></span></h3><p>Schedule a command to find a descendant of this element. If the element cannot be found, a <a href="enum_bot_ErrorCode.html#NO_SUCH_ELEMENT"><code>bot.ErrorCode.NO_SUCH_ELEMENT</code></a> 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 <a href="module_selenium-webdriver_class_WebElementPromise.html#isElementPresent"><code>#isElementPresent</code></a> instead.</p> <p>The search criteria for an element may be defined using one of the factories in the <a href="namespace_webdriver_By.html"><code>webdriver.By</code></a> namespace, or as a short-hand <a href="namespace_webdriver_By.html#By.Hash"><code>webdriver.By.Hash</code></a> object. For example, the following two statements are equivalent:</p> <pre><code>var e1 &#61; element.findElement(By.id(&#39;foo&#39;)); var e2 &#61; element.findElement({id:&#39;foo&#39;}); </code></pre> <p>You may also provide a custom locator function, which takes as input this WebDriver instance and returns a <a href="class_webdriver_WebElement.html"><code>webdriver.WebElement</code></a>, or a promise that will resolve to a WebElement. For example, to find the first visible link on a page, you could write:</p> <pre><code>var link &#61; element.findElement(firstVisibleLink); function firstVisibleLink(element) { var links &#61; element.findElements(By.tagName(&#39;a&#39;)); return webdriver.promise.filter(links, function(link) { return links.isDisplayed(); }).then(function(visibleLinks) { return visibleLinks[0]; }); } </code></pre> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#findElement">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>locator<code>(<a href="class_webdriver_Locator.html">webdriver.Locator</a>|{className: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{css: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{id: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{js: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{linkText: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{name: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{partialLinkText: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{tagName: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{xpath: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>})</code><dd><p>The locator strategy to use when searching for the element.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_WebElement.html">webdriver.WebElement</a></code><dd><p>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.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="findElements" class="function"><div><h3>findElements(<wbr>locator)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1900">code »</a></span></h3><p>Schedules a command to find all of the descendants of this element that match the given search criteria.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#findElements">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>locator<code>(<a href="class_webdriver_Locator.html">webdriver.Locator</a>|{className: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{css: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{id: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{js: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{linkText: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{name: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{partialLinkText: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{tagName: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{xpath: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>})</code><dd><p>The locator strategy to use when searching for the elements.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&lt;<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>&gt;&gt;</code><dd><p>A promise that will resolve to an array of WebElements.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getAttribute" class="function"><div><h3>getAttribute(<wbr>attributeName)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2077">code »</a></span></h3><p>Schedules a command to query for the value of the given attribute of the element. Will return the current value, even if it has been modified after the page has been loaded. More exactly, this method will return the value of the given attribute, unless that attribute is not present, in which case the value of the property with the same name is returned. If neither value is set, null is returned (for example, the &#34;value&#34; property of a textarea element). The &#34;style&#34; attribute is converted as best can be to a text representation with a trailing semi-colon. The following are deemed to be &#34;boolean&#34; attributes and will return either &#34;true&#34; or null:</p> <p>async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, spellcheck, truespeed, willvalidate</p> <p>Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:</p> <ul><li>&#34;class&#34;</li><li>&#34;readonly&#34;</li></ul> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getAttribute">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>attributeName<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The name of the attribute to query.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code><dd><p>A promise that will be resolved with the attribute&#39;s value. The returned value will always be either a string or null.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getCssValue" class="function"><div><h3>getCssValue(<wbr>cssStyleProperty)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2039">code »</a></span></h3><p>Schedules a command to query for the computed style of the element represented by this instance. If the element inherits the named style from its parent, the parent will be queried for its value. Where possible, color values will be converted to their hex representation (e.g. #00ff00 instead of rgb(0, 255, 0)).</p> <p><em>Warning:</em> the value returned will be as the browser interprets it, so it may be tricky to form a proper assertion.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getCssValue">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>cssStyleProperty<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The name of the CSS style property to look up.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code><dd><p>A promise that will be resolved with the requested CSS value.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getDriver" class="function"><div><h3>getDriver()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1768">code »</a></span></h3><p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getDriver">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_WebDriver.html">webdriver.WebDriver</a></code><dd><p>The parent driver for this instance.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getId" class="function"><div><h3>getId()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2264">code »</a></span></h3><p>Defers returning the element ID until the wrapped WebElement has been resolved.</p> <p><b>Overrides: </b><a href="class_webdriver_WebElement.html#getId">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;{ELEMENT: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}&gt;</code><dd><p>A promise that resolves to this element&#39;s JSON representation as defined by the WebDriver wire protocol.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getInnerHtml" class="function"><div><h3>getInnerHtml()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2214">code »</a></span></h3><p>Schedules a command to retrieve the inner HTML of this element.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getInnerHtml">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code><dd><p>A promise that will be resolved with the element&#39;s inner HTML.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getLocation" class="function"><div><h3>getLocation()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2118">code »</a></span></h3><p>Schedules a command to compute the location of this element in page space.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getLocation">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;{x: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, y: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>}&gt;</code><dd><p>A promise that will be resolved to the element&#39;s location as a <code>{x:number, y:number}</code> object.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getOuterHtml" class="function"><div><h3>getOuterHtml()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2195">code »</a></span></h3><p>Schedules a command to retrieve the outer HTML of this element.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getOuterHtml">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code><dd><p>A promise that will be resolved with the element&#39;s outer HTML.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getRawId" class="function"><div><h3>getRawId()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1790">code »</a></span></h3><p>Returns the raw ID string ID for this element.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getRawId">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code><dd><p>A promise that resolves to this element&#39;s raw ID as a string value.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getSize" class="function"><div><h3>getSize()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2105">code »</a></span></h3><p>Schedules a command to compute the size of this element&#39;s bounding box, in pixels.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getSize">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;{height: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, width: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>}&gt;</code><dd><p>A promise that will be resolved with the element&#39;s size as a <code>{width:number, height:number}</code> object.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getTagName" class="function"><div><h3>getTagName()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2017">code »</a></span></h3><p>Schedules a command to query for the tag/node name of this element.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getTagName">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code><dd><p>A promise that will be resolved with the element&#39;s tag name.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="getText" class="function"><div><h3>getText()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2091">code »</a></span></h3><p>Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#getText">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code><dd><p>A promise that will be resolved with the element&#39;s visible text.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="isDisplayed" class="function"><div><h3>isDisplayed()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2183">code »</a></span></h3><p>Schedules a command to test whether this element is currently displayed.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#isDisplayed">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>&gt;</code><dd><p>A promise that will be resolved with whether this element is currently visible on the page.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="isElementPresent" class="function"><div><h3>isElementPresent(<wbr>locator)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1884">code »</a></span></h3><p>Schedules a command to test if there is at least one descendant of this element that matches the given search criteria.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#isElementPresent">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>locator<code>(<a href="class_webdriver_Locator.html">webdriver.Locator</a>|{className: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{css: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{id: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{js: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{linkText: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{name: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{partialLinkText: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{tagName: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{xpath: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>})</code><dd><p>The locator strategy to use when searching for the element.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>&gt;</code><dd><p>A promise that will be resolved with whether an element could be located on the page.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="isEnabled" class="function"><div><h3>isEnabled()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2131">code »</a></span></h3><p>Schedules a command to query whether the DOM element represented by this instance is enabled, as dicted by the <code>disabled</code> attribute.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#isEnabled">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>&gt;</code><dd><p>A promise that will be resolved with whether this element is currently enabled.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="isPending" class="function"><div><h3>isPending()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2248">code »</a></span></h3><p><b>Specified by: </b><a href="interface_webdriver_promise_Thenable.html#isPending">webdriver.promise.Thenable</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd><p>Whether this promise&#39;s value is still being computed.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="isSelected" class="function"><div><h3>isSelected()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2143">code »</a></span></h3><p>Schedules a command to query whether this element is selected.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#isSelected">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>&gt;</code><dd><p>A promise that will be resolved with whether this element is currently selected.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="sendKeys" class="function"><div><h3>sendKeys(<wbr>var_args)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1979">code »</a></span></h3><p>Schedules a command to type a sequence on the DOM element represented by this instance.</p> <p>Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is processed in the keysequence, that key state is toggled until one of the following occurs:</p> <ul><li> <p>The modifier key is encountered again in the sequence. At this point the state of the key is toggled (along with the appropriate keyup/down events).</p> </li><li> <p>The <a href="enum_webdriver_Key.html#NULL"><code>webdriver.Key.NULL</code></a> key is encountered in the sequence. When this key is encountered, all modifier keys current in the down state are released (with accompanying keyup events). The NULL key can be used to simulate common keyboard shortcuts:</p> <pre><code> element.sendKeys(&#34;text was&#34;, webdriver.Key.CONTROL, &#34;a&#34;, webdriver.Key.NULL, &#34;now text is&#34;); // Alternatively: element.sendKeys(&#34;text was&#34;, webdriver.Key.chord(webdriver.Key.CONTROL, &#34;a&#34;), &#34;now text is&#34;); </code></pre> </li><li> <p>The end of the keysequence is encountered. When there are no more keys to type, all depressed modifier keys are released (with accompanying keyup events).</p> </li></ul> <p>If this element is a file input (<code>&lt;input type&#61;&#34;file&#34;&gt;</code>), the specified key sequence should specify the path to the file to attach to the element. This is analgous to the user clicking &#34;Browse...&#34; and entering the path into the file select dialog.</p> <pre><code>var form &#61; driver.findElement(By.css(&#39;form&#39;)); var element &#61; form.findElement(By.css(&#39;input[type&#61;file]&#39;)); element.sendKeys(&#39;/path/to/file.txt&#39;); form.submit(); </code></pre> <p>For uploads to function correctly, the entered path must reference a file on the <em>browser&#39;s</em> machine, not the local machine running this script. When running against a remote Selenium server, a <a href="class_webdriver_FileDetector.html"><code>webdriver.FileDetector</code></a> may be used to transparently copy files to the remote machine before attempting to upload them in the browser.</p> <p><strong>Note:</strong> On browsers where native keyboard events are not supported (e.g. Firefox on OS X), key events will be synthesized. Special punctionation keys will be synthesized according to a standard QWERTY en-us keyboard layout.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#sendKeys">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>var_args<code>...(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;)</code><dd><p>The sequence of keys to type. All arguments will be joined into a single sequence.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>&gt;</code><dd><p>A promise that will be resolved when all keys have been typed.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="serialize" class="function"><div><h3>serialize()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1798">code »</a></span></h3><p>Returns either this instance&#39;s serialized represention, if immediately available, or a promise for its serialized representation. This function is conceptually equivalent to objects that have a <code>toJSON()</code> property, except the serialize() result may be a promise or an object containing a promise (which are not directly JSON friendly).</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#serialize">webdriver.WebElement</a><br><b>Overrides: </b><a href="class_webdriver_Serializable.html#serialize">webdriver.Serializable</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code>(<a href="class_webdriver_WebElement.html#WebElement.Id">webdriver.WebElement.Id</a>|IThenable&lt;<a href="class_webdriver_WebElement.html#WebElement.Id">webdriver.WebElement.Id</a>&gt;)</code><dd><p>This instance&#39;s serialized wire format.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="submit" class="function"><div><h3>submit()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2157">code »</a></span></h3><p>Schedules a command to submit the form containing this element (or this element if it is a FORM element). This command is a no-op if the element is not contained in a form.</p> <p><b>Defined by: </b><a href="class_webdriver_WebElement.html#submit">webdriver.WebElement</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>&gt;</code><dd><p>A promise that will be resolved when the form has been submitted.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="then" class="function"><div><h3>then(<wbr>opt_callback, opt_errback)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2251">code »</a></span></h3><p>Registers listeners for when this instance is resolved.</p> <p><b>Specified by: </b><a href="interface_webdriver_promise_Thenable.html#then">webdriver.promise.Thenable</a>, <a href="#then">IThenable</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_callback<code>?function(T): (R|IThenable&lt;R&gt;)=</code><dd><p>The function to call if this promise is successfully resolved. The function should expect a single argument: the promise&#39;s resolved value.</p> <dt>opt_errback<code>?function(*): (R|IThenable&lt;R&gt;)=</code><dd><p>The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code><dd><p>A new promise which will be resolved with the result of the invoked callback.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="thenCatch" class="function"><div><h3>thenCatch(<wbr>errback)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2254">code »</a></span></h3><p>Registers a listener for when this promise is rejected. This is synonymous with the <code>catch</code> clause in a synchronous API:</p> <pre><code>// Synchronous API: try { doSynchronousWork(); } catch (ex) { console.error(ex); } // Asynchronous promise API: doAsynchronousWork().thenCatch(function(ex) { console.error(ex); }); </code></pre> <p><b>Specified by: </b><a href="interface_webdriver_promise_Thenable.html#thenCatch">webdriver.promise.Thenable</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>errback<code>function(*): (R|IThenable&lt;R&gt;)</code><dd><p>The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code><dd><p>A new promise which will be resolved with the result of the invoked callback.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="thenFinally" class="function"><div><h3>thenFinally(<wbr>callback)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l2257">code »</a></span></h3><p>Registers a listener to invoke when this promise is resolved, regardless of whether the promise&#39;s value was successfully computed. This function is synonymous with the <code>finally</code> clause in a synchronous API:</p> <pre><code>// Synchronous API: try { doSynchronousWork(); } finally { cleanUp(); } // Asynchronous promise API: doAsynchronousWork().thenFinally(cleanUp); </code></pre> <p><strong>Note:</strong> similar to the <code>finally</code> clause, if the registered callback returns a rejected promise or throws an error, it will silently replace the rejection error (if any) from this promise:</p> <pre><code>try { throw Error(&#39;one&#39;); } finally { throw Error(&#39;two&#39;); // Hides Error: one } promise.rejected(Error(&#39;one&#39;)) .thenFinally(function() { throw Error(&#39;two&#39;); // Hides Error: one }); </code></pre> <p><b>Specified by: </b><a href="interface_webdriver_promise_Thenable.html#thenFinally">webdriver.promise.Thenable</a></p><div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>callback<code>function(): (R|IThenable&lt;R&gt;)</code><dd><p>The function to call when this promise is resolved.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code><dd><p>A promise that will be fulfilled with the callback result.</p> </dl></div></div></div></div></article><nav><h3><a href="index.html" tabindex="2">Overview</a></h3><div><input type="checkbox" id="nav-modules" checked/><label for="nav-modules"><h3><span class="selectable" tabindex="2">Modules</span></h3></label><div id="nav-modules-view"></div></div><div><input type="checkbox" id="nav-types" checked/><label for="nav-types"><h3><span class="selectable" tabindex="2">Types</span></h3></label><div id="nav-types-view"></div></div><h3><a href="Changes.html" tabindex="2">Changes</a></h3></nav></main><footer><div><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></div></footer><script src="types.js"></script><script src="dossier.js"></script>