Working on DragAndDrop:
====================
To perfrom drag and drop operations we can use "Actions" class
Syntax:
Actions act = new Actions(driver);
act.dragAndDrop(ele1, ele2).build().perform();
Exp: Write script to perform drag and drop operation in "http://jqueryui.com/droppable/"
WebDriver driver= new FirefoxDriver();
driver.get("http://jqueryui.com/droppable/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.switchTo().frame(0);
WebElement ele1=driver.findElement(By.id("draggable"));
WebElement ele2=driver.findElement(By.id("droppable"));
Actions act= new Actions(driver);
act.dragAndDrop(ele1, ele2).build().perform();
Exp: Create script to DragAndDrop "Daily Deals" in http://ebay.in
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://ebay.in");
Thread.sleep(10000);
Actions act = new Actions(driver);
WebElement ele1 = driver.findElement(By.id("gh-btn"));
WebElement ele2 = driver.findElement(By.xpath("//h2[text()='Daily Deals']"));
act.dragAndDrop(ele1, ele2).build().perform();
No comments:
Post a Comment