selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
38 lines • 6.67 kB
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>WebDriver.TargetLocator</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>Namespace:</b> <a href="namespace_webdriver.html">webdriver</a></div><div class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1544">View Source</a></div><h1>class WebDriver.TargetLocator</h1><p>An interface for changing the focus of the driver to another frame or window.</p>
<h3>new WebDriver.TargetLocator(<wbr>driver)</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 driver.</p>
</dl></div></div><h2>Instance Methods</h2><div id="activeElement" class="function"><div><h3>activeElement()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1557">code »</a></span></h3><p>Schedules a command retrieve the <code>document.activeElement</code> element on
the current document, or <code>document.body</code> if activeElement is not
available.</p>
<div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_WebElementPromise.html">webdriver.WebElementPromise</a></code><dd><p>The active element.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="alert" class="function"><div><h3>alert()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1634">code »</a></span></h3><p>Schedules a command to change focus to the active alert dialog. This command
will return a <a href="enum_bot_ErrorCode.html#NO_SUCH_ALERT"><code>bot.ErrorCode.NO_SUCH_ALERT</code></a> error if an alert dialog
is not currently open.</p>
<div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_AlertPromise.html">webdriver.AlertPromise</a></code><dd><p>The open alert.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="defaultContent" class="function"><div><h3>defaultContent()<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1571">code »</a></span></h3><p>Schedules a command to switch focus of all future commands to the first frame
on the page.</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><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>></code><dd><p>A promise that will be resolved
when the driver has changed focus to the default content.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="frame" class="function"><div><h3>frame(<wbr>nameOrIndex)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1599">code »</a></span></h3><p>Schedules a command to switch the focus of all future commands to another
frame on the page.</p>
<p>If the frame is specified by a number, the command will switch to the frame
by its (zero-based) index into
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Window.frames">window.frames</a>.</p>
<p>If the frame is specified by a string, the command will select the frame by
its name or ID. To select sub-frames, simply separate the frame names/IDs by
dots. As an example, "main.child" will select the frame with the name "main"
and then its child "child".</p>
<p>If the specified frame can not be found, the deferred result will errback
with a <a href="enum_bot_ErrorCode.html#NO_SUCH_FRAME"><code>bot.ErrorCode.NO_SUCH_FRAME</code></a> error.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>nameOrIndex<code>(<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/Number">number</a>)</code><dd><p>The frame locator.</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><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>></code><dd><p>A promise that will be resolved
when the driver has changed focus to the specified frame.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="window" class="function"><div><h3>window(<wbr>nameOrHandle)<span class="codelink"><a href="source/lib/webdriver/webdriver.js.src.html#l1620">code »</a></span></h3><p>Schedules a command to switch the focus of all future commands to another
window. Windows may be specified by their <code>window.name</code> attribute or
by its handle (as returned by <a href="class_webdriver_WebDriver.html"><code>webdriver.WebDriver#getWindowHandles</code></a>).</p>
<p>If the specificed window can not be found, the deferred result will errback
with a <a href="enum_bot_ErrorCode.html#NO_SUCH_WINDOW"><code>bot.ErrorCode.NO_SUCH_WINDOW</code></a> error.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>nameOrHandle<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The name or window handle of the window to
switch focus to.</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><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>></code><dd><p>A promise that will be resolved
when the driver has changed focus to the specified window.</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>