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);
  3.  WebElement source = driver.findElement(By.xpath(“myXpath”));
  4. //source element which you want to drag
  6.  WebElement target = driver.findElement(By.xpath(“myXpath”));
  7. //target where you want to drop
  9.  action .dragAndDrop(source,target).perform();
Facebook Comments
(Visited 6 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

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

%d bloggers like this: