How to automate drag & drop functionality using Selenium…
The drag and drop action is done with the help of a mouse. It happens when we drag and then place an element from one place to another. This is a common scenario when we try to move a file from one folder to another by simply drag and drop action.
Selenium uses the Actions class to perform the drag drop action. The dragAndDrop(source, destination) is a method under Actions class to do drag and drop operation. The method will first do a left click on the element, then continue the click to hold the source element. Next it shall move to the destination location and release the mouse.

Our aim to drag and drop the first box to the second box.
Example
Code Implementation.
package RK1.Building_a_selenium_project;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class DragandDrop {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "F:\\Work Environment\\MyProject\\chromedriver.exe");
WebDriver wd = new ChromeDriver();
String url = "https://jqueryui.com/droppable/";
wd.get(url);
wd.manage().window().maximize();
wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
wd.switchTo().frame(0);
// identify source and target element
WebElement s=wd.findElement(By.id("draggable"));
WebElement t=wd.findElement(By.id("droppable"));
//Actions class with dragAndDrop()
Actions act = new Actions(wd);
act.dragAndDrop(s, t).build().perform();
wd.quit();
}
}