Tuesday, February 16, 2016

Actions Class -- Drag and Drop

Go to site :
http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/draganddrop/defaultcs.aspx
Drag and drop the components (means drag location Brazil and drop to other component.

public class ActionsDragDrop {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver=new FirefoxDriver();
driver.get("http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/draganddrop/defaultcs.aspx");
Thread.sleep(4000);
Actions builder = new Actions(driver);
// get the source element
WebElement sour = driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceholder1_RadListBox1_i7']"));
// get the destination element path
WebElement dest = driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceholder1_RadListBox2']/div[2]"));
Thread.sleep(4000);
// using drag drop methods..
// using drag and drop methods we can move item from location A to Location B
builder.dragAndDrop(sour, dest).perform();
}
}