class ActionSequence

Alias for webdriver.ActionSequence

Class for defining sequences of complex user interactions. Each sequence will not be executed until #perform is called.

Example:

new webdriver.ActionSequence(driver).
    keyDown(webdriver.Key.SHIFT).
    click(element1).
    click(element2).
    dragAndDrop(element3, element4).
    keyUp(webdriver.Key.SHIFT).
    perform();

new ActionSequence(driver)

Parameters
driverwebdriver.WebDriver

The driver instance to use.

Instance Methods

click(opt_elementOrButton, opt_button)code »

Clicks a mouse button.

If an element is provided, the mouse will first be moved to the center of that element. This is equivalent to:

sequence.mouseMove(element).click()
Parameters
opt_elementOrButton?(webdriver.WebElement|number)=

Either the element to interact with or the button to click with. Defaults to webdriver.Button.LEFT if neither an element nor button is specified.

opt_buttonnumber=

The button to use. Defaults to webdriver.Button.LEFT. Ignored if a button is provided as the first argument.

Returns
webdriver.ActionSequence

A self reference.


doubleClick(opt_elementOrButton, opt_button)code »

Double-clicks a mouse button.

If an element is provided, the mouse will first be moved to the center of that element. This is equivalent to:

sequence.mouseMove(element).doubleClick()

Warning: this method currently only supports the left mouse button. See issue 4047.

Parameters
opt_elementOrButton?(webdriver.WebElement|number)=

Either the element to interact with or the button to click with. Defaults to webdriver.Button.LEFT if neither an element nor button is specified.

opt_buttonnumber=

The button to use. Defaults to webdriver.Button.LEFT. Ignored if a button is provided as the first argument.

Returns
webdriver.ActionSequence

A self reference.


dragAndDrop(element, location)code »

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).

Parameters
elementwebdriver.WebElement

The element to drag.

location(webdriver.WebElement|{x: number, y: number})

The location to drag to, either as another WebElement or an offset in pixels.

Returns
webdriver.ActionSequence

A self reference.


keyDown(key)code »

Performs a modifier key press. The modifier key is not released until #keyUp or #sendKeys is called. The key press will be targetted at the currently focused element.

Parameters
keystring

The modifier key to push. Must be one of {ALT, CONTROL, SHIFT, COMMAND, META}.

Returns
webdriver.ActionSequence

A self reference.

Throws
Error

If the key is not a valid modifier key.


keyUp(key)code »

Performs a modifier key release. The release is targetted at the currently focused element.

Parameters
keystring

The modifier key to release. Must be one of {ALT, CONTROL, SHIFT, COMMAND, META}.

Returns
webdriver.ActionSequence

A self reference.

Throws
Error

If the key is not a valid modifier key.


mouseDown(opt_elementOrButton, opt_button)code »

Presses a mouse button. The mouse button will not be released until #mouseUp 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.

If an element is provided, the mouse will first be moved to the center of that element. This is equivalent to:

sequence.mouseMove(element).mouseDown()

Warning: this method currently only supports the left mouse button. See issue 4047.

Parameters
opt_elementOrButton?(webdriver.WebElement|number)=

Either the element to interact with or the button to click with. Defaults to webdriver.Button.LEFT if neither an element nor button is specified.

opt_buttonnumber=

The button to use. Defaults to webdriver.Button.LEFT. Ignored if a button is provided as the first argument.

Returns
webdriver.ActionSequence

A self reference.


mouseMove(location, opt_offset)code »

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).

Parameters
location(webdriver.WebElement|{x: number, y: number})

The location to drag to, as either another WebElement or an offset in pixels.

opt_offset{x: number, y: number}=

If the target location is defined as a webdriver.WebElement, 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.

Returns
webdriver.ActionSequence

A self reference.


mouseUp(opt_elementOrButton, opt_button)code »

Releases a mouse button. Behavior is undefined for calling this function without a previous call to #mouseDown.

If an element is provided, the mouse will first be moved to the center of that element. This is equivalent to:

sequence.mouseMove(element).mouseUp()

Warning: this method currently only supports the left mouse button. See issue 4047.

Parameters
opt_elementOrButton?(webdriver.WebElement|number)=

Either the element to interact with or the button to click with. Defaults to webdriver.Button.LEFT if neither an element nor button is specified.

opt_buttonnumber=

The button to use. Defaults to webdriver.Button.LEFT. Ignored if a button is provided as the first argument.

Returns
webdriver.ActionSequence

A self reference.


perform()code »

Executes this action sequence.

Returns
webdriver.promise.Promise

A promise that will be resolved once this sequence has completed.


sendKeys(var_args)code »

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.

Parameters
var_args...(string|Array<string>)

The keys to type.

Returns
webdriver.ActionSequence

A self reference.

Throws
Error

If the key is not a valid modifier key.