How to drag and drop elements in selenium webdriver?

In this video we will see the drag and drop functionality using selenium werbdriver. How to automate the process of dragging one element on other element using selenium.

I hope you like this video. For any questions, suggestions or appreciation please contact us at: or email at:

Complete source code:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

public class DemoDragAndDrop {

 public static void main(String[] args) throws InterruptedException {
  // TODO Auto-generated method stub
  System.setProperty("", "C:\\work\\Selenium\\chromedriver_win32_version98\\chromedriver.exe");
  WebDriver driver = new ChromeDriver();
  WebElement source = driver.findElement(By.xpath("//h1[text() = 'Block 1']"));
  WebElement target = driver.findElement(By.xpath("//h1[text() = 'Block 3']"));
  Actions act = new Actions(driver);
  act.dragAndDrop(source, target).perform();



Leave a Reply