ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

How do Perform Drag and Drop using WebDriver?

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

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!