Skip to content

Instantly share code, notes, and snippets.

@azakordonets
Created August 27, 2014 18:09
Show Gist options
  • Select an option

  • Save azakordonets/a006853f9532671aac6b to your computer and use it in GitHub Desktop.

Select an option

Save azakordonets/a006853f9532671aac6b to your computer and use it in GitHub Desktop.
/**
* A convenience method that performs click-and-hold at the location of the source element, moves by a given offset, then releases the mouse.
* @param slider webElement
* @param xOffset - horizontal move offset. Positive value means moving to the right, negative - to the left
* @param yOffset - vertical move offset. Positive value means moving up, negative - down
* @throws Exception
*/
public void dragAndDrop(WebElement slider, int xOffset, int yOffset) throws Exception {
Actions moveSlider = new Actions(driver);
Action action = moveSlider.clickAndHold(slider)
.moveByOffset(xOffset, yOffset)
.release()
.build();
action.perform();
Thread.sleep(500);
waitForPageToLoad();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment