|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openqa.selenium.interactions.Actions
public class Actions
The user-facing API for emulating complex user gestures. Use this class rather than using the Keyboard or Mouse directly. Implements the builder pattern: Builds a CompositeAction containing all actions specified by the method calls.
Field Summary | |
---|---|
protected CompositeAction |
action
|
protected Keyboard |
keyboard
|
protected Mouse |
mouse
|
Constructor Summary | |
---|---|
Actions(Keyboard keyboard)
Only used by the TouchActions class. |
|
Actions(Keyboard keyboard,
Mouse mouse)
A constructor that should only be used when the keyboard or mouse were extended to provide additional functionality (for example, dragging-and-dropping from the desktop). |
|
Actions(WebDriver driver)
Default constructor - uses the default keyboard, mouse implemented by the driver. |
Method Summary | |
---|---|
Action |
build()
Generates a composite action containinig all actions so far, ready to be performed (and resets the internal builder state, so subsequent calls to build() will contain fresh sequences). |
Actions |
click()
Clicks at the current mouse location. |
Actions |
click(WebElement onElement)
Clicks in the middle of the given element. |
Actions |
clickAndHold()
Clicks (without releasing) at the current mouse location. |
Actions |
clickAndHold(WebElement onElement)
Clicks (without releasing) in the middle of the given element. |
Actions |
contextClick(WebElement onElement)
Performs a context-click at middle of the given element. |
Actions |
doubleClick()
Performs a double-click at the current mouse location. |
Actions |
doubleClick(WebElement onElement)
Performs a double-click at middle of the given element. |
Actions |
dragAndDrop(WebElement source,
WebElement target)
A convenience method that performs click-and-hold at the location of the source element, moves to the location of the target element, then releases the mouse. |
Actions |
dragAndDropBy(WebElement source,
int xOffset,
int yOffset)
A convenience method that performs click-and-hold at the location of the source element, moves by a given offset, then releases the mouse. |
Actions |
keyDown(Keys theKey)
Performs a modifier key press. |
Actions |
keyDown(WebElement element,
Keys theKey)
Performs a modifier key press after focusing on an element. |
Actions |
keyUp(Keys theKey)
Performs a modifier key release. |
Actions |
keyUp(WebElement element,
Keys theKey)
Performs a modifier key release after focusing on an element. |
Actions |
moveByOffset(int xOffset,
int yOffset)
Moves the mouse from its current position (or 0,0) by the given offset. |
Actions |
moveToElement(WebElement toElement)
Moves the mouse to the middle of the element. |
Actions |
moveToElement(WebElement toElement,
int xOffset,
int yOffset)
Moves the mouse to an offset from the top-left corner of the element. |
void |
perform()
A convenience method for performing the actions without calling build() first. |
Actions |
release()
Releases the depressed left mouse button at the current mouse location. |
Actions |
release(WebElement onElement)
Releases the depressed left mouse button, in the middle of the given element. |
Actions |
sendKeys(java.lang.CharSequence... keysToSend)
Sends keys to the active element. |
Actions |
sendKeys(WebElement element,
java.lang.CharSequence... keysToSend)
Equivalent to calling: Actions.click(element).sendKeys(keysToSend). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Mouse mouse
protected Keyboard keyboard
protected CompositeAction action
Constructor Detail |
---|
public Actions(WebDriver driver)
driver
- the driver providing the implementations to use.public Actions(Keyboard keyboard, Mouse mouse)
keyboard
- the Keyboard
implementation to delegate to.mouse
- the Mouse
implementation to delegate to.public Actions(Keyboard keyboard)
keyboard
- implementation to delegate to.Method Detail |
---|
public Actions keyDown(Keys theKey)
theKey
- Either Keys.SHIFT
, Keys.ALT
or Keys.CONTROL
. If the
provided key is none of those, IllegalArgumentException
is thrown.
public Actions keyDown(WebElement element, Keys theKey)
theKey
- Either Keys.SHIFT
, Keys.ALT
or Keys.CONTROL
. If the
provided key is none of those, IllegalArgumentException
is thrown.
keyDown(org.openqa.selenium.Keys)
public Actions keyUp(Keys theKey)
theKey
- Either Keys.SHIFT
, Keys.ALT
or Keys.CONTROL
.
public Actions keyUp(WebElement element, Keys theKey)
theKey
- Either Keys.SHIFT
, Keys.ALT
or Keys.CONTROL
.
on behaviour regarding non-depressed modifier keys.
public Actions sendKeys(java.lang.CharSequence... keysToSend)
WebElement.sendKeys(CharSequence...)
on the active element in two ways:
keysToSend
- The keys.
WebElement.sendKeys(CharSequence...)
public Actions sendKeys(WebElement element, java.lang.CharSequence... keysToSend)
WebElement.sendKeys(CharSequence...)
- see
sendKeys(CharSequence...)
for details how.
element
- element to focus on.keysToSend
- The keys.
#sendKeys(CharSequence...)}
public Actions clickAndHold(WebElement onElement)
onElement
- Element to move to and click.
public Actions clickAndHold()
public Actions release(WebElement onElement)
clickAndHold()
first will result in
undefined behaviour.
onElement
- Element to release the mouse button above.
public Actions release()
release(org.openqa.selenium.WebElement)
public Actions click(WebElement onElement)
onElement
- Element to click.
public Actions click()
moveToElement(org.openqa.selenium.WebElement, int, int)
or
moveByOffset(int, int)
.
public Actions doubleClick(WebElement onElement)
onElement
- Element to move to.
public Actions doubleClick()
public Actions moveToElement(WebElement toElement)
toElement
- element to move to.
public Actions moveToElement(WebElement toElement, int xOffset, int yOffset)
toElement
- element to move to.xOffset
- Offset from the top-left corner. A negative value means coordinates right from
the element.yOffset
- Offset from the top-left corner. A negative value means coordinates above
the element.
public Actions moveByOffset(int xOffset, int yOffset)
xOffset
- horizontal offset. A negative value means moving the mouse left.yOffset
- vertical offset. A negative value means moving the mouse up.
MoveTargetOutOfBoundsException
- if the provided offset is outside the document's
boundaries.public Actions contextClick(WebElement onElement)
onElement
- Element to move to.
public Actions dragAndDrop(WebElement source, WebElement target)
source
- element to emulate button down at.target
- element to move to and release the mouse at.
public Actions dragAndDropBy(WebElement source, int xOffset, int yOffset)
source
- element to emulate button down at.xOffset
- horizontal move offset.yOffset
- vertical move offset.
public Action build()
public void perform()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |