Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

DraggingAndDrop using Selenium Java

package com.example.actions;

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

WebDriver driver;

public void setup(){

driver=new FirefoxDriver();

driver.manage().window().maximize();

driver.get("http://jqueryui.com/draggable/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

}

public void menuandSubMenu(){
System.out.println(driver.findElements(By.tagName("iframe")).size());
// Switch to Frames
// WebElement iframe=driver.findElement(By.xpath("//iframe[@id='demo-frame']"));
driver.switchTo().frame(0);

//root element
WebElement mainMenu=driver.findElement(By.xpath(".//*[@id='draggable']"));
Actions  action=new Actions(driver);
//dragging and drop
action.dragAndDropBy(mainMenu, 50 ,50).build().perform();
System.out.println("Hello...completed");

}


public static void main(String[] args) {

DraggingAndDrop dd=new DraggingAndDrop();
dd.setup();
dd.menuandSubMenu();
}

}

Post a Comment

0 Comments