Tuesday, August 13, 2013

Handling Keyboard & Mouse Events in Selenium

Handling special keyboard and mouse events : It contains the Actions and the Action classes that are needed when executing these events.

ClickAndHold() : Clicks (without releasing) at the current mouse location.ContextClick() : Performs a context-click at the current mouse location.
DoubleClick() : Performs a double-click at the current mouse location.
dragAndDrop(source, target) : Performs click-and-hold at the location of the source element, moves by a given offset, then releases the mouse.
keyDown(modifier_key) : Performs a modifier key press. Does not release the modifier key - subsequent interactions may assume it's kept pressed.
Parameters:
modifier_key – any of the modifier keys (Keys.ALT, Keys.SHIFT, or Keys.CONTROL)

keyUp(modifier _key) : Performs a key release.
Parameters:
modifier_key – any of the modifier keys (Keys.ALT, Keys.SHIFT, or Keys.CONTROL)

moveByOffset(x-offset, y-offset) : Moves the mouse from its current position (or 0,0) by the given offset.
Parameters:
x-offset- horizontal offset. A negative value means moving the mouse left.
y-offset- vertical offset. A negative value means moving the mouse up.

moveToElement(toElement) : Moves the mouse to the middle of the element. Parameters:
toElement- element to move to.

Release() : Releases the depressed left mouse button at the current mouse locationsendKeys(onElement, charsequence) : Sends a series of keystrokes onto the element. Parameters:
onElement - element that will receive the keystrokes, usually a text field
charsequence – any string value representing the sequence of keystrokes to be sent.

No comments: