Showing posts with label how to do dragAndDrop. Show all posts
Showing posts with label how to do dragAndDrop. Show all posts

Wednesday, 10 December 2014

how to do dragAndDrop

We have Actions class in Selenium Webdriver

Actions class have the  method dragAndDrop(source,target) for this purpose.

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.Actions;
import java.util.concurrent.TimeUnit;


public class DragNdrop {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);


        driver.get("http://yuiblog.com/sandbox/yui/3.2.0pr1/examples/dd/groups-drag_clean.html");
        Actions act = new Actions(driver);
        WebElement source1 = driver.findElement(By.id("pt1"));
        WebElement target1 = driver.findElement(By.id("t2"));
        act.dragAndDrop(source1,target1).perform();
        
        
    }

}