Created
February 6, 2015 04:02
-
-
Save udayanem/2e15a421311cddbfa366 to your computer and use it in GitHub Desktop.
How to perform drag and drop operation using webdriver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.TimeUnit; | |
import org.openqa.selenium.*; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.interactions.Actions; | |
public class DragAndDropExample | |
{ | |
public static void main(String[] args) throws InterruptedException | |
{ | |
WebDriver driver=new FirefoxDriver(); | |
driver.get("http://test.cita.illinois.edu/aria/draganddrop/draganddrop3.php"); | |
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); | |
driver.manage().window().maximize(); | |
driver.findElement(By.id("startButton")).click(); | |
Thread.sleep(3000); | |
WebElement target=driver.findElement(By.xpath("//td[@id='cell1x1']")); | |
WebElement source =driver.findElement(By.xpath("//div[@id='ex']/img")); | |
Actions action=new Actions(driver); | |
// action.clickAndHold(source).moveToElement(target).release(target).perform(); | |
// action.clickAndHold(source).moveToElement(target).release(target).build().perform(); | |
// action.clickAndHold(source).moveToElement(target).release().perform(); | |
action.dragAndDrop(source, target).perform(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment