Drag and Drop in Selenium Webdriver

Handling "drag and drop" actions using WebDriver (Selenium 2)

package selenium_examples;

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 Test {

drag and drop selenium webdriver
 public static void main(String[] args) {


     WebDriver driver = new FirefoxDriver();
     driver.get("http://jqueryui.com/droppable/");
     driver.switchTo().frame(driver.findElement(By.className("demo-frame")));
     WebElement dragElement=driver.findElement(By.id("draggable")); 
     WebElement dropElement=driver.findElement(By.id("droppable"));
    
     Actions builder = new Actions(driver);
     builder.dragAndDrop(dragElement, dropElement).perform();
     System.out.println("Done!");
    
    
  }
}

No comments:

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge