Sunday, November 8, 2015

Performing drag-and-drop operation

In Selenium WebDriver, dragAndDrop method available in Actions class. Actions class supports all advanced user interactions such as firing mouse and keyboard events on a web page.

Below is the sample logic to perform drag and drop operation on a page using Actions class.

Logic

    WebElement elementToDrag = driver.findElement(By.id("DragThis"));
    WebElement elementToDropAt = driver.findElement(By.id("DropHere"));
  
    Actions action = new Actions(driver);
    action.dragAndDrop(elementToDrag, elementToDropAt).perform();


dragAndDrop method in actions class accepts two parameters as input. One is the element to drag and another one is the destination to drop element.


Related Topic
Advanced User Interactions API

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.