Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. System.setProperty("webdriver.chrome.driver", "F:\Drivers\chromedriver.exe");
  2. d = new ChromeDriver();
  3. d.manage().window().maximize();
  4. d.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  5. Actions act = new Actions(d);
  6. d.get("https://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/nested");
  7. Thread.sleep(2000);
  8. ((JavascriptExecutor)d).executeScript("scroll(4,400)");
  9. WebElement src = d.findElement(By.xpath("html/body/div[2]/div[2]/div[2]/div[1]/div[1]/div[2]/div/div/ul/li[1]/div"));
  10. System.out.println("The src element is:" +src.getText());
  11. WebElement destn = d.findElement(By.xpath("html/body/div[2]/div[2]/div[2]/div[1]/div[1]/div[1]/div/div/ul/li[1]/div/div[2]/ul/li/div"));
  12. System.out.println("The src element is:" +destn.getText());
  13. org.openqa.selenium.Point pt1 = src.getLocation();
  14. org.openqa.selenium.Point pt2 = destn.getLocation();
  15. int xCord1 = pt1.getX();
  16. int yCord1 = pt1.getY();
  17. int xCord2 = pt2.getX();
  18. int yCord2 = pt2.getY();
  19. System.out.println("The X & Y cordinate of the src is:" +xCord1+ " & " +yCord1);
  20. System.out.println("The X & Y cordinate of the destn is:" +xCord2+ " & " +yCord2);
  21. Actions ac = new Actions(d);
  22. Action dragAndDrop = ac.clickAndHold(src).moveToElement(destn, 334, 661).release(destn).build();
  23. dragAndDrop.perform();
Add Comment
Please, Sign In to add comment