Friday, 4 August 2017

Code Example - Drag And Drop

package com.seleniumWebdriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;

/**
 * @Blog Name : Selenium Code Example
 * @author Deepak Gupta
 * @Created Date 4-08-2017
 *
 */
public class DragAndDrop extends SuperTestNG {

public void handleFrame() {
WebElement ele = driver.findElement(By.className("demo-frame"));
driver.switchTo().frame(ele);

}

@Test
public void handleDragAndDrop() {
try {
driver.get("https://jqueryui.com/droppable/");
handleFrame();
WebElement src = driver.findElement(By.xpath("//*[@id='draggable']/p"));
WebElement tar = driver.findElement(By.id("droppable"));

Actions act = new Actions(driver);
act.dragAndDrop(src, tar).perform();
Thread.sleep(3000);

} catch (Exception e) {
e.printStackTrace();
}
}
}

No comments:

Post a Comment

Code Example - File Download By Robot Class In Firefox Browser

Exported from Notepad++ package com . practiceCode ; import java . awt . AWTException ; import java . awt . Robot ; import j...