Friday 9 August 2013

Drag and drop in Selenium!!

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;


public class DragDrop {


public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://dl.dropbox.com/u/55228056/DragDropDemo.html");
WebElement source = driver.findElement(By.id("draggable"));
WebElement target = driver.findElement(By.id("droppable"));
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(source)
.moveToElement(target)
.release(target)
.build();
dragAndDrop.perform();
}

}

No comments:

Post a Comment