# Class webdriver.ActionSequence

code »

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();

## Constructor

webdriver.ActionSequence ( driver )

Parameters

driver: `!webdriver.WebDriver`
  The driver instance to use.

Show:PublicProtectedPrivate

## Instance Methods

code » click ( opt_elementOrButton, opt_button ) ⇒ `!webdriver.ActionSequence`

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|webdriver.Button)=`
  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_button: `webdriver.Button=`
  The button to use. Defaults to `webdriver.Button.LEFT`. Ignored if a button is provided as the first argument.

Returns

A self reference.

code » doubleClick ( opt_elementOrButton, opt_button ) ⇒ `!webdriver.ActionSequence`

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 http://code.google.com/p/selenium/issues/detail?id=4047

Parameters

opt_elementOrButton: `(webdriver.WebElement|webdriver.Button)=`
  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_button: `webdriver.Button=`
  The button to use. Defaults to `webdriver.Button.LEFT`. Ignored if a button is provided as the first argument.

Returns

A self reference.

code » dragAndDrop ( element, location ) ⇒ `!webdriver.ActionSequence`

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

element: `!webdriver.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

A self reference.

code » keyDown ( key ) ⇒ `!webdriver.ActionSequence`

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

key: `!webdriver.Key`
  The modifier key to push. Must be one of {ALT, CONTROL, SHIFT, COMMAND, META}.

Returns

A self reference.

Throws

`Error`
  If the key is not a valid modifier key.

code » keyUp ( key ) ⇒ `!webdriver.ActionSequence`

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

Parameters

key: `!webdriver.Key`
  The modifier key to release. Must be one of {ALT, CONTROL, SHIFT, COMMAND, META}.

Returns

A self reference.

Throws

`Error`
  If the key is not a valid modifier key.

code » mouseDown ( opt_elementOrButton, opt_button ) ⇒ `!webdriver.ActionSequence`

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 http://code.google.com/p/selenium/issues/detail?id=4047

Parameters

opt_elementOrButton: `(webdriver.WebElement|webdriver.Button)=`
  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_button: `webdriver.Button=`
  The button to use. Defaults to `webdriver.Button.LEFT`. Ignored if a button is provided as the first argument.

Returns

A self reference.

code » mouseMove ( location, opt_offset ) ⇒ `!webdriver.ActionSequence`

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

A self reference.

code » mouseUp ( opt_elementOrButton, opt_button ) ⇒ `!webdriver.ActionSequence`

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 http://code.google.com/p/selenium/issues/detail?id=4047

Parameters

opt_elementOrButton: `(webdriver.WebElement|webdriver.Button)=`
  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_button: `webdriver.Button=`
  The button to use. Defaults to `webdriver.Button.LEFT`. Ignored if a button is provided as the first argument.

Returns

A self reference.

code » perform ( ) ⇒ `!webdriver.promise.Promise`

Executes this action sequence.

Returns

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

code » scheduleKeyboardAction_ ( description, keys ) ⇒ `!webdriver.ActionSequence`

Schedules a keyboard action.

Parameters

description: `string`
  A simple descriptive label for the scheduled action.
keys: `!Array`
  The keys to send.

Returns

A self reference.

code » scheduleMouseAction_ ( description, commandName, opt_elementOrButton, opt_button ) ⇒ `!webdriver.ActionSequence`

Schedules a mouse action.

Parameters

description: `string`
  A simple descriptive label for the scheduled action.
commandName: `!webdriver.CommandName`
  The name of the command.
opt_elementOrButton: `(webdriver.WebElement|webdriver.Button)=`
  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_button: `webdriver.Button=`
  The button to use. Defaults to `webdriver.Button.LEFT`. Ignored if the previous argument is provided as a button.

Returns

A self reference.

code » schedule_ ( description, command )

Schedules an action to be executed each time `#perform` is called on this instance.

Parameters

description: `string`
  A description of the command.
command: `!webdriver.Command`
  The command.

code » sendKeys ( var_args ) ⇒ `!webdriver.ActionSequence`

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|!webdriver.Key|!Array)`
  The keys to type.

Returns

A self reference.

Throws

`Error`
  If the key is not a valid modifier key.

## Instance Properties

code » actions_ : `!Array`
code » driver_ : `!webdriver.WebDriver`

## Static Functions

code » webdriver.ActionSequence.checkModifierKey_ ( key )

Checks that a key is a modifier key.

Parameters

key: `!webdriver.Key`
  The key to check.

Throws

`Error`
  If the key is not a modifier key.