Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Selenium WebDriver Handling Drag and Drop functionality

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 572
    Comment on it

    In this blog, we discuss about handling the drag and drop functionality  in Selenium WebDriver.

    Scenario to be automated:


    • Launch the web browser
    • Open your application (eg. "")
    • Drag the element
    • Drop that element to the other place


    WebDriver Code goes as below:


    import java.util.concurrent.TimeUnit;
    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;
    public class dragdrop {
    	public static void main(String[] args) {
    		WebDriver driver = new FirefoxDriver();
    		  driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
    		  WebElement drag = driver.findElement(By.xpath(".//*[@id='dragdiv']"));
    		  WebElement drop = driver.findElement(By.xpath(".//*[@id='dropdiv']"));
    		  Actions action = new Actions(driver);
    		  action.dragAndDrop(drag, drop).perform();


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: