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 {
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!");
}
}
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 {
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:
Post a Comment