Category:
Selenium WebDriver
Approach 1:
Actions act=new Actions(driver);
// find element which we need to drag
WebElement drag=driver.findElement(By.xpath("".//*[@id='draggable']""));
// find element which we need to drop
WebElement drop=driver.findElement(By.xpath("".//*[@id='droppable']""));
// this will drag element to destination
act.dragAndDrop(drag, drop).build().perform();
Approach 2:
Actions act=new Actions(driver);
// find element which we need to drag
WebElement source=driver.findElement(By.xpath(""(//span[text()='Thrillers'])[1]""));
WebElement destination=driver.findElement(By.xpath(""(//span[text()='History'])[2]""));
// it will click and hold the triller box and move to element will move cursor to history in another box and then release
act.clickAndHold(source).pause(2000).moveToElement(destination).release().build().perform();