Class ActionSequence

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

Example:


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

Hierarchy

Index

Constructor methods

Methods

Constructor methods

constructor(driver: WebDriver): ActionSequence

constructor

Parameters

  • driver: WebDriver

    The driver instance to use.

Returns

ActionSequence

Methods

public click(opt_elementOrButton?: WebElement, opt_button?: number): 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?: WebElement optional

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

  • opt_button?: number optional

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

Returns

ActionSequence

A self reference.

public click(opt_elementOrButton?: number): ActionSequence

Parameters

  • opt_elementOrButton?: number optional

Returns

ActionSequence

public doubleClick(opt_elementOrButton?: WebElement, opt_button?: number): 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?: WebElement optional

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

  • opt_button?: number optional

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

Returns

ActionSequence

A self reference.

public doubleClick(opt_elementOrButton?: number): ActionSequence

Parameters

  • opt_elementOrButton?: number optional

Returns

ActionSequence

public dragAndDrop(element: WebElement, location: WebElement): 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

Returns

ActionSequence

A self reference.

public dragAndDrop(element: WebElement, location: ILocation): ActionSequence

Parameters

Returns

ActionSequence

public keyDown(key: string): ActionSequence

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

throws

{Error} If the key is not a valid modifier key.

Parameters

  • key: string

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

Returns

ActionSequence

A self reference.

public keyUp(key: string): ActionSequence

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

throws

{Error} If the key is not a valid modifier key.

Parameters

  • key: string

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

Returns

ActionSequence

A self reference.

public mouseDown(opt_elementOrButton?: WebElement, opt_button?: number): ActionSequence

Presses a mouse button. The mouse button will not be released until {@link #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?: WebElement optional

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

  • opt_button?: number optional

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

Returns

ActionSequence

A self reference.

public mouseDown(opt_elementOrButton?: number): ActionSequence

Parameters

  • opt_elementOrButton?: number optional

Returns

ActionSequence

public mouseMove(location: WebElement, opt_offset?: ILocation): 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

Returns

ActionSequence

A self reference.

public mouseMove(location: ILocation): ActionSequence

Parameters

Returns

ActionSequence

public mouseUp(opt_elementOrButton?: WebElement, opt_button?: number): ActionSequence

Releases a mouse button. Behavior is undefined for calling this function without a previous call to {@link #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?: WebElement optional

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

  • opt_button?: number optional

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

Returns

ActionSequence

A self reference.

public mouseUp(opt_elementOrButton?: number): ActionSequence

Parameters

  • opt_elementOrButton?: number optional

Returns

ActionSequence

public perform(): Promise

Executes this action sequence.

Returns

Promise

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

public sendKeys(var_args?: Array<any>): 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.

throws

{Error} If the key is not a valid modifier key.

Parameters

  • var_args?: Array<any> optional
    The keys to type.
    

Returns

ActionSequence

A self reference.