selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
115 lines • 15.8 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>ActionSequence</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/actionsequence.js.src.html#l45">View Source</a></div><h1>class ActionSequence</h1><p>Class for defining sequences of complex user interactions. Each sequence
will not be executed until <a href="class_webdriver_ActionSequence.html#perform"><code>#perform</code></a> is called.</p>
<p>Example:</p>
<pre><code>new webdriver.ActionSequence(driver).
keyDown(webdriver.Key.SHIFT).
click(element1).
click(element2).
dragAndDrop(element3, element4).
keyUp(webdriver.Key.SHIFT).
perform();
</code></pre>
<h3>new ActionSequence(<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 driver instance to use.</p>
</dl></div></div><h2>Instance Methods</h2><div id="click" class="function"><div><h3>click(<wbr>opt_elementOrButton, opt_button)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l249">code »</a></span></h3><p>Clicks a mouse button.</p>
<p>If an element is provided, the mouse will first be moved to the center
of that element. This is equivalent to:</p>
<pre><code>sequence.mouseMove(element).click()
</code></pre>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_elementOrButton<code>?(<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)=</code><dd><p>Either
the element to interact with or the button to click with.
Defaults to <a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a> if neither an element nor
button is specified.</p>
<dt>opt_button<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd><p>The button to use. Defaults to
<a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a>. Ignored if a button is provided as the
first argument.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="doubleClick" class="function"><div><h3>doubleClick(<wbr>opt_elementOrButton, opt_button)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l276">code »</a></span></h3><p>Double-clicks a mouse button.</p>
<p>If an element is provided, the mouse will first be moved to the center of
that element. This is equivalent to:</p>
<pre><code>sequence.mouseMove(element).doubleClick()
</code></pre>
<p>Warning: this method currently only supports the left mouse button. See
<a href="http://code.google.com/p/selenium/issues/detail?id=4047">issue 4047</a>.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_elementOrButton<code>?(<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)=</code><dd><p>Either
the element to interact with or the button to click with.
Defaults to <a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a> if neither an element nor
button is specified.</p>
<dt>opt_button<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd><p>The button to use. Defaults to
<a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a>. Ignored if a button is provided as the
first argument.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="dragAndDrop" class="function"><div><h3>dragAndDrop(<wbr>element, location)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l227">code »</a></span></h3><p>Convenience function for performing a "drag and drop" manuever. The target
element may be moved to the location of another element, or by an offset (in
pixels).</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>element<code><a href="class_webdriver_WebElement.html">webdriver.WebElement</a></code><dd><p>The element to drag.</p>
<dt>location<code>(<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>|{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>})</code><dd><p>The
location to drag to, either as another WebElement or an offset in pixels.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="keyDown" class="function"><div><h3>keyDown(<wbr>key)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l324">code »</a></span></h3><p>Performs a modifier key press. The modifier key is <em>not released</em>
until <a href="class_webdriver_ActionSequence.html#keyUp"><code>#keyUp</code></a> or <a href="class_webdriver_ActionSequence.html#sendKeys"><code>#sendKeys</code></a> is called. The key press will be
targetted at the currently focused element.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>key<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The modifier key to push. Must be one of
{ALT, CONTROL, SHIFT, COMMAND, META}.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div><div class="fn-details"><div><b>Throws</b></div><dl><dt><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a></code><dd><p>If the key is not a valid modifier key.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="keyUp" class="function"><div><h3>keyUp(<wbr>key)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l338">code »</a></span></h3><p>Performs a modifier key release. The release is targetted at the currently
focused element.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>key<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The modifier key to release. Must be one of
{ALT, CONTROL, SHIFT, COMMAND, META}.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div><div class="fn-details"><div><b>Throws</b></div><dl><dt><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a></code><dd><p>If the key is not a valid modifier key.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="mouseDown" class="function"><div><h3>mouseDown(<wbr>opt_elementOrButton, opt_button)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l183">code »</a></span></h3><p>Presses a mouse button. The mouse button will not be released until
<a href="class_webdriver_ActionSequence.html#mouseUp"><code>#mouseUp</code></a> is called, regardless of whether that call is made in this
sequence or another. The behavior for out-of-order events (e.g. mouseDown,
click) is undefined.</p>
<p>If an element is provided, the mouse will first be moved to the center
of that element. This is equivalent to:</p>
<pre><code>sequence.mouseMove(element).mouseDown()
</code></pre>
<p>Warning: this method currently only supports the left mouse button. See
<a href="http://code.google.com/p/selenium/issues/detail?id=4047">issue 4047</a>.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_elementOrButton<code>?(<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)=</code><dd><p>Either
the element to interact with or the button to click with.
Defaults to <a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a> if neither an element nor
button is specified.</p>
<dt>opt_button<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd><p>The button to use. Defaults to
<a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a>. Ignored if a button is provided as the
first argument.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="mouseMove" class="function"><div><h3>mouseMove(<wbr>location, opt_offset)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l102">code »</a></span></h3><p>Moves the mouse. The location to move to may be specified in terms of the
mouse's current location, an offset relative to the top-left corner of an
element, or an element (in which case the middle of the element is used).</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>location<code>(<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>|{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>})</code><dd><p>The
location to drag to, as either another WebElement or an offset in pixels.</p>
<dt>opt_offset<code>{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>}=</code><dd><p>If the target <code>location</code>
is defined as a <a href="class_webdriver_WebElement.html"><code>webdriver.WebElement</code></a>, this parameter defines an
offset within that element. The offset should be specified in pixels
relative to the top-left corner of the element's bounding box. If
omitted, the element's center will be used as the target offset.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="mouseUp" class="function"><div><h3>mouseUp(<wbr>opt_elementOrButton, opt_button)<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l211">code »</a></span></h3><p>Releases a mouse button. Behavior is undefined for calling this function
without a previous call to <a href="class_webdriver_ActionSequence.html#mouseDown"><code>#mouseDown</code></a>.</p>
<p>If an element is provided, the mouse will first be moved to the center
of that element. This is equivalent to:</p>
<pre><code>sequence.mouseMove(element).mouseUp()
</code></pre>
<p>Warning: this method currently only supports the left mouse button. See
<a href="http://code.google.com/p/selenium/issues/detail?id=4047">issue 4047</a>.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_elementOrButton<code>?(<a href="class_webdriver_WebElement.html">webdriver.WebElement</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)=</code><dd><p>Either
the element to interact with or the button to click with.
Defaults to <a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a> if neither an element nor
button is specified.</p>
<dt>opt_button<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd><p>The button to use. Defaults to
<a href="enum_webdriver_Button.html#LEFT"><code>webdriver.Button.LEFT</code></a>. Ignored if a button is provided as the
first argument.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="perform" class="function"><div><h3>perform()<span class="codelink"><a href="source/lib/webdriver/actionsequence.js.src.html#l75">code »</a></span></h3><p>Executes this action sequence.</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></code><dd><p>A promise that will be resolved once
this sequence has completed.</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/actionsequence.js.src.html#l353">code »</a></span></h3><p>Simulates typing multiple keys. Each modifier key encountered in the
sequence will not be released until it is encountered again. All key events
will be targetted at the currently focused element.</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="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>)</code><dd><p>The keys to type.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_ActionSequence.html">webdriver.ActionSequence</a></code><dd><p>A self reference.</p>
</dl></div><div class="fn-details"><div><b>Throws</b></div><dl><dt><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a></code><dd><p>If the key is not a valid modifier key.</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>