Skip to content

Instantly share code, notes, and snippets.

@ultimate-qa2
Created February 26, 2021 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ultimate-qa2/ac6d4dd97252ae0ea33f567d8c5ac0b5 to your computer and use it in GitHub Desktop.
Save ultimate-qa2/ac6d4dd97252ae0ea33f567d8c5ac0b5 to your computer and use it in GitHub Desktop.
Mouse actions in Java
// Clicks in the middle of the given element.
click(WebElement target);
// Clicks (without releasing) at the current mouse location.
clickAndHold(WebElement target);
// Performs a context-click at middle of the given element. First performs a mouseMove to the location of the element.
contextClick(WebElement target);
// Performs a double-click at middle of the given element.
doubleClick(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.
dragAndDrop(WebElement source, WebElement target);
// A convenience method that performs click-and-hold at the location of the source element,
// moves by a given offset, then releases the mouse.
dragAndDrop(WebElement source, int xOffset, int yOffset);
// Moves the mouse to the middle of the element.
moveToElement(WebElement target);
// Moves the mouse to an offset from the top-left corner of the element.
moveToElement(WebElement source, int xOffset, int yOffset);
// Releases the depressed left mouse button at the current mouse location.
release();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment