-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDragDrop.java
More file actions
44 lines (30 loc) · 1.4 KB
/
DragDrop.java
File metadata and controls
44 lines (30 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//drap and drop actions on website
package automation;
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 DragDrop {
public static void main(String[] args) throws Throwable {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "D:\\Quastech\\Software\\geckodriver-v0.30.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.dhtmlgoodies.com/scripts/drag-drop-custom/demo-drag-drop-3.html");
driver.manage().window().maximize();
//box is on left hand side of website
WebElement from = driver.findElement(By.id("box7"));
//empty space on right hand side of website
WebElement to = driver.findElement(By.id("box107"));
//In this program, we have to move box on LHS to empty space on RHS, for that make use of Action class obj and drag and drop function
Actions act = new Actions(driver);
act.dragAndDrop(from, to).build().perform();
Thread.sleep(3000);
WebElement from2 = driver.findElement(By.id("box5"));
WebElement to2 = driver.findElement(By.id("box105"));
Actions act2 = new Actions(driver);
act2.dragAndDrop(from2, to2).build().perform();
Thread.sleep(3000);
driver.close();
}
}