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
    • 371
    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. "http://only-testing-blog.blogspot.in/2014/09/drag-and-drop.html")
    • 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.get("http://only-testing-blog.blogspot.in/2014/09/drag-and-drop.html");
    		  
    		  driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
    		  driver.manage().window().maximize();
    		  
    		  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
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
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: