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
IWebDriverThe 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
Build()
Builds the sequence of actions.
public IAction Build()
Returns
Click()
Clicks the mouse at the last known mouse coordinates.
public Actions Click()
Returns
Click(IWebElement)
Clicks the mouse on the specified element.
public Actions Click(IWebElement onElement)
Parameters
onElement
IWebElementThe element on which to click.
Returns
ClickAndHold()
Clicks and holds the mouse button at the last known mouse coordinates.
public Actions ClickAndHold()
Returns
ClickAndHold(IWebElement)
Clicks and holds the mouse button down on the specified element.
public Actions ClickAndHold(IWebElement onElement)
Parameters
onElement
IWebElementThe element on which to click and hold.
Returns
ContextClick()
Right-clicks the mouse at the last known mouse coordinates.
public Actions ContextClick()
Returns
ContextClick(IWebElement)
Right-clicks the mouse on the specified element.
public Actions ContextClick(IWebElement onElement)
Parameters
onElement
IWebElementThe element on which to right-click.
Returns
DoubleClick()
Double-clicks the mouse at the last known mouse coordinates.
public Actions DoubleClick()
Returns
DoubleClick(IWebElement)
Double-clicks the mouse on the specified element.
public Actions DoubleClick(IWebElement onElement)
Parameters
onElement
IWebElementThe element on which to double-click.
Returns
DragAndDrop(IWebElement, IWebElement)
Performs a drag-and-drop operation from one element to another.
public Actions DragAndDrop(IWebElement source, IWebElement target)
Parameters
source
IWebElementThe element on which the drag operation is started.
target
IWebElementThe element on which the drop is performed.
Returns
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
IWebElementThe element on which the drag operation is started.
offsetX
intThe horizontal offset to which to move the mouse.
offsetY
intThe vertical offset to which to move the mouse.
Returns
GetLocatableFromElement(IWebElement)
Gets the ILocatable instance of the specified IWebElement.
protected static ILocatable GetLocatableFromElement(IWebElement element)
Parameters
element
IWebElementThe 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
IWebElementThe element to which to send the key command.
theKey
stringThe key to be sent.
Returns
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
stringThe key to be sent.
Returns
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
IWebElementThe element to which to send the key command.
theKey
stringThe key to be sent.
Returns
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
stringThe key to be sent.
Returns
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
intThe horizontal offset to which to move the mouse.
offsetY
intThe vertical offset to which to move the mouse.
Returns
MoveToElement(IWebElement)
Moves the mouse to the specified element.
public Actions MoveToElement(IWebElement toElement)
Parameters
toElement
IWebElementThe element to which to move the mouse.
Returns
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
IWebElementThe element to which to move the mouse.
offsetX
intThe horizontal offset to which to move the mouse.
offsetY
intThe vertical offset to which to move the mouse.
Returns
Perform()
Performs the currently built action.
public void Perform()
Release()
Releases the mouse button at the last known mouse coordinates.
public Actions Release()
Returns
Release(IWebElement)
Releases the mouse button on the specified element.
public Actions Release(IWebElement onElement)
Parameters
onElement
IWebElementThe element on which to release the button.
Returns
SendKeys(IWebElement, string)
Sends a sequence of keystrokes to the specified element in the browser.
public Actions SendKeys(IWebElement element, string keysToSend)
Parameters
element
IWebElementThe element to which to send the keystrokes.
keysToSend
stringThe keystrokes to send to the browser.
Returns
SendKeys(string)
Sends a sequence of keystrokes to the browser.
public Actions SendKeys(string keysToSend)
Parameters
keysToSend
stringThe keystrokes to send to the browser.