Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

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

WebDriver driver;

public void setup(){

driver=new FirefoxDriver();

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

driver.get("http://jqueryui.com/droppable/");
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 source=driver.findElement(By.xpath(".//*[@id='draggable']"));

WebElement des=driver.findElement(By.xpath(".//*[@id='droppable']"));
Actions  action=new Actions(driver);

action.dragAndDrop(source,des ).build().perform();
 
}


public static void main(String[] args) {

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

}

Post a Comment

0 Comments