How do Perform Drag and Drop using WebDriver?

0
4

In this post, we will discuss drag and drop using WebDriver. For this purpose, we need to use Action class.
Under Actions, class various method is defined to serve various actions that are needed to be performed. One such method is dragAndDrop().
Below is the sample code:

  1. Actions action = new Actions(driver);
  2.  
  3.  WebElement source = driver.findElement(By.xpath(“myXpath”));
  4. //source element which you want to drag
  5.  
  6.  WebElement target = driver.findElement(By.xpath(“myXpath”));
  7. //target where you want to drop
  8.  
  9.  action .dragAndDrop(source,target).perform();
Facebook Comments
(Visited 9 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here