Skip to content

Actions

This is a JavaScript wrapper for Actions of Selenium .NET library.

Action Summary

Action Description
Build Builds the sequence of actions.
Click Clicks the mouse on the specified element.
ClickAndHold Clicks and holds the mouse button down on the specified element.
ContextClick Right-clicks the mouse on the specified element.
DoubleClick Double-clicks the mouse on the specified element.
DragAndDrop Performs a drag-and-drop operation from one element to another.
DragAndDropToOffset Performs a drag-and-drop operation on one element to a specified offset.
KeyDown Sends a modifier key down message to the specified element in the browser.
KeyUp Sends a modifier key up message to the specified element in the browser.
MoveByOffset Moves the mouse to the specified offset of the last known mouse coordinates.
MoveToElement Moves the mouse to the specified offset of the top-left corner of the specified element.
Perform Performs the currently built action.
Release Releases the mouse button on the specified element.
SendKeys Sends a sequence of keystrokes to the specified element in the browser.

Action Detail

Build

Builds the sequence of actions.

WebDriver.Actions().KeyDown("Shift").Click(obj.element).KeyUp("Shift").Build().Perform();

Returns:

A self-reference.

Click

Clicks the mouse on the specified element. If no element is specified clicks the mouse at the last known mouse coordinates.

WebDriver.Actions().Click(obj.element).Perform();

Parameters:

Name Type Description
el WebElementWrapper The element on which to click.
Optional.

Returns:

A self-reference.

ClickAndHold

Clicks and holds the mouse button down on the specified element. If no element is specified clicks and holds the mouse button at the last known mouse coordinates.

WebDriver.Actions().ClickAndHold(obj.element).Perform();

Parameters:

Name Type Description
el WebElementWrapper The element on which to click and hold.
Optional.

Returns:

A self-reference.

ContextClick

Right-clicks the mouse on the specified element. If no element is specified right-clicks the mouse at the last known mouse coordinates.

WebDriver.Actions().ContextClick(obj.element).Perform();

Parameters:

Name Type Description
el WebElementWrapper The element on which to right-click.
Optional.

Returns:

A self-reference.

DoubleClick

Double-clicks the mouse on the specified element. If no element is specified double-clicks the mouse at the last known mouse coordinates.

WebDriver.Actions().DoubleClick(obj.element).Perform();

Parameters:

Name Type Description
el WebElementWrapper The element on which to double-click.
Optional.

Returns:

A self-reference.

DragAndDrop

Performs a drag-and-drop operation from one element to another.

WebDriver.Actions().DragAndDrop(obj.element,target.element).Perform();

Parameters:

Name Type Description
source WebElementWrapper The element on which the drag operation is started.
target WebElementWrapper The element on which the drop is performed.

Returns:

A self-reference.

DragAndDropToOffset

Performs a drag-and-drop operation on one element to a specified offset.

WebDriver.Actions().DragAndDropToOffset(obj.element, 100, 50).Perform();

Parameters:

Name Type Description
source WebElementWrapper The element on which the drag operation is started.
offsetX number The horizontal offset to which to move the mouse.
offsetY number The vertical offset to which to move the mouse.

Returns:

A self-reference.

KeyDown

Sends a modifier key down message to the specified element in the browser. If no element is specified sends a modifier key down message to the browser.

WebDriver.Actions().KeyDown("Shift").Perform();

Parameters:

Name Type Description
theKey string The key to be sent. Accepts "Shift", "Control" and "Alt".
el WebElementWrapper The element to which to send the key command.
Optional.

Returns:

A self-reference.

KeyUp

Sends a modifier key up message to the specified element in the browser. If no element is specified sends a modifier key up message to the browser.

WebDriver.Actions().KeyUp("Shift").Perform();

Parameters:

Name Type Description
theKey string The key to be sent. Accepts "Shift", "Control" and "Alt".
el WebElementWrapper The element to which to send the key command.
Optional.

Returns:

A self-reference.

MoveByOffset

Moves the mouse to the specified offset of the last known mouse coordinates.

WebDriver.Actions().MoveByOffset(100,100).Perform();

Parameters:

Name Type Description
offsetX number The horizontal offset to which to move the mouse.
offsetY number The vertical offset to which to move the mouse.

Returns:

A self-reference.

MoveToElement

Moves the mouse to the specified offset of the top-left corner of the specified element. If offset is not specified moves the mouse to the specified element.

WebDriver.Actions().MoveByOffset(obj.element,100,100).Perform();

Parameters:

Name Type Description
el WebElementWrapper The element to which to move the mouse.
offsetX number The horizontal offset to which to move the mouse.
Optional.
offsetY number The vertical offset to which to move the mouse.
Optional.

Returns:

A self-reference.

Perform

Performs the currently built action.

WebDriver.Actions().KeyDown("Alt").DoubleClick(obj.element).KeyUp("Alt").Perform();

Release

Releases the mouse button on the specified element. If no element is specified releases the mouse button at the last known mouse coordinates.

WebDriver.Actions().Release(obj.element).Perform();

Parameters:

Name Type Description
el WebElementWrapper The element on which to release the button.
Optional.

Returns:

A self-reference.

SendKeys

Sends a sequence of keystrokes to the specified element in the browser. If no element is specified sends a sequence of keystrokes to the browser.

WebDriver.Actions().SendKeys("hello",obj.element).Perform();

Parameters:

Name Type Description
keysToSend string The keystrokes to send to the browser.
el WebElementWrapper The element to which to send the keystrokes.
Optional.

Returns:

A self-reference.