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:
Actions action = new Actions(driver);
WebElement source = driver.findElement(By.xpath(“myXpath”));
//source element which you want to drag
WebElement target = driver.findElement(By.xpath(“myXpath”));
//target where you want to drop