Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created September 28, 2020 13:45
Show Gist options
  • Save muditlambda/f2b0e5ac6a1636aeca784d94c96a4b9a to your computer and use it in GitHub Desktop.
Save muditlambda/f2b0e5ac6a1636aeca784d94c96a4b9a to your computer and use it in GitHub Desktop.
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 ActionsTest {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\Driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.w3schools.com/html/html5_draganddrop.asp");
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
Actions action = new Actions(driver);
WebElement source = driver.findElement(By.xpath("//*[@id=\"drag1\"]"));
WebElement destination = driver.findElement(By.xpath("//*[@id=\"div2\"]"));
action.clickAndHold(source).moveToElement(destination).release().build().perform();
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment