Table of Contents

Class Actions

Namespace
OpenQA.Selenium.Interactions
Assembly
WebDriver.dll

Provides a mechanism for building advanced interactions with the browser.

public class Actions
Inheritance
Actions
Derived
Inherited Members

Constructors

Actions(IWebDriver)

Initializes a new instance of the Actions class.

public Actions(IWebDriver driver)

Parameters

driver IWebDriver

The IWebDriver object on which the actions built will be performed.

Methods

AddAction(IAction)

Adds an action to current list of actions to be performed.

protected void AddAction(IAction actionToAdd)

Parameters

actionToAdd IAction

The IAction to be added.

Build()

Builds the sequence of actions.

public IAction Build()

Returns

IAction

A composite IAction which can be used to perform the actions.

Click()

Clicks the mouse at the last known mouse coordinates.

public Actions Click()

Returns

Actions

A self-reference to this Actions.

Click(IWebElement)

Clicks the mouse on the specified element.

public Actions Click(IWebElement onElement)

Parameters

onElement IWebElement

The element on which to click.

Returns

Actions

A self-reference to this Actions.

ClickAndHold()

Clicks and holds the mouse button at the last known mouse coordinates.

public Actions ClickAndHold()

Returns

Actions

A self-reference to this Actions.

ClickAndHold(IWebElement)

Clicks and holds the mouse button down on the specified element.

public Actions ClickAndHold(IWebElement onElement)

Parameters

onElement IWebElement

The element on which to click and hold.

Returns

Actions

A self-reference to this Actions.

ContextClick()

Right-clicks the mouse at the last known mouse coordinates.

public Actions ContextClick()

Returns

Actions

A self-reference to this Actions.

ContextClick(IWebElement)

Right-clicks the mouse on the specified element.

public Actions ContextClick(IWebElement onElement)

Parameters

onElement IWebElement

The element on which to right-click.

Returns

Actions

A self-reference to this Actions.

DoubleClick()

Double-clicks the mouse at the last known mouse coordinates.

public Actions DoubleClick()

Returns

Actions

A self-reference to this Actions.

DoubleClick(IWebElement)

Double-clicks the mouse on the specified element.

public Actions DoubleClick(IWebElement onElement)

Parameters

onElement IWebElement

The element on which to double-click.

Returns

Actions

A self-reference to this Actions.

DragAndDrop(IWebElement, IWebElement)

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

public Actions DragAndDrop(IWebElement source, IWebElement target)

Parameters

source IWebElement

The element on which the drag operation is started.

target IWebElement

The element on which the drop is performed.

Returns

Actions

A self-reference to this Actions.

DragAndDropToOffset(IWebElement, int, int)

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

public Actions DragAndDropToOffset(IWebElement source, int offsetX, int offsetY)

Parameters

source IWebElement

The element on which the drag operation is started.

offsetX int

The horizontal offset to which to move the mouse.

offsetY int

The vertical offset to which to move the mouse.

Returns

Actions

A self-reference to this Actions.

GetLocatableFromElement(IWebElement)

Gets the ILocatable instance of the specified IWebElement.

protected static ILocatable GetLocatableFromElement(IWebElement element)

Parameters

element IWebElement

The IWebElement to get the location of.

Returns

ILocatable

The ILocatable of the IWebElement.

KeyDown(IWebElement, string)

Sends a modifier key down message to the specified element in the browser.

public Actions KeyDown(IWebElement element, string theKey)

Parameters

element IWebElement

The element to which to send the key command.

theKey string

The key to be sent.

Returns

Actions

A self-reference to this Actions.

Exceptions

ArgumentException

If the key sent is not is not one of Shift, Control, or Alt.

KeyDown(string)

Sends a modifier key down message to the browser.

public Actions KeyDown(string theKey)

Parameters

theKey string

The key to be sent.

Returns

Actions

A self-reference to this Actions.

Exceptions

ArgumentException

If the key sent is not is not one of Shift, Control, or Alt.

KeyUp(IWebElement, string)

Sends a modifier up down message to the specified element in the browser.

public Actions KeyUp(IWebElement element, string theKey)

Parameters

element IWebElement

The element to which to send the key command.

theKey string

The key to be sent.

Returns

Actions

A self-reference to this Actions.

Exceptions

ArgumentException

If the key sent is not is not one of Shift, Control, or Alt.

KeyUp(string)

Sends a modifier key up message to the browser.

public Actions KeyUp(string theKey)

Parameters

theKey string

The key to be sent.

Returns

Actions

A self-reference to this Actions.

Exceptions

ArgumentException

If the key sent is not is not one of Shift, Control, or Alt.

MoveByOffset(int, int)

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

public Actions MoveByOffset(int offsetX, int offsetY)

Parameters

offsetX int

The horizontal offset to which to move the mouse.

offsetY int

The vertical offset to which to move the mouse.

Returns

Actions

A self-reference to this Actions.

MoveToElement(IWebElement)

Moves the mouse to the specified element.

public Actions MoveToElement(IWebElement toElement)

Parameters

toElement IWebElement

The element to which to move the mouse.

Returns

Actions

A self-reference to this Actions.

MoveToElement(IWebElement, int, int)

Moves the mouse to the specified offset of the top-left corner of the specified element.

public Actions MoveToElement(IWebElement toElement, int offsetX, int offsetY)

Parameters

toElement IWebElement

The element to which to move the mouse.

offsetX int

The horizontal offset to which to move the mouse.

offsetY int

The vertical offset to which to move the mouse.

Returns

Actions

A self-reference to this Actions.

Perform()

Performs the currently built action.

public void Perform()

Release()

Releases the mouse button at the last known mouse coordinates.

public Actions Release()

Returns

Actions

A self-reference to this Actions.

Release(IWebElement)

Releases the mouse button on the specified element.

public Actions Release(IWebElement onElement)

Parameters

onElement IWebElement

The element on which to release the button.

Returns

Actions

A self-reference to this Actions.

SendKeys(IWebElement, string)

Sends a sequence of keystrokes to the specified element in the browser.

public Actions SendKeys(IWebElement element, string keysToSend)

Parameters

element IWebElement

The element to which to send the keystrokes.

keysToSend string

The keystrokes to send to the browser.

Returns

Actions

A self-reference to this Actions.

SendKeys(string)

Sends a sequence of keystrokes to the browser.

public Actions SendKeys(string keysToSend)

Parameters

keysToSend string

The keystrokes to send to the browser.

Returns

Actions

A self-reference to this Actions.