0

I need to drag an element from one location to other using the selenium webdriver for angula6 element

I have tried using

Actions act = new Actions(driver); act.dragAndDrop(from, to).build().perform();

but it does not work.

import org.openqa.selenium.interactions.Actions;

String obj = "/html[1]/body[1]/app-root[1]/app-frame[1]/div[1]/adsvalu-create-sales-target[1]/section[1]/div[1]/div[1]/section[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]";
String obj1 = "/html[1]/body[1]/app-root[1]/app-frame[1]/div[1]/adsvalu-create-sales-target[1]/section[1]/div[1]/div[1]/section[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]";

WebElement from = driver.findElement(By.xpath(obj));
WebElement to = driver.findElement(By.xpath(obj1));
Actions act = new Actions(driver);
act.dragAndDrop(from, to).build().perform();

There is no error but the drag and drop action is not happening

5
  • Relevant HTML please? Commented Sep 13, 2019 at 9:05
  • @DebanjanB the xpaths are added Commented Sep 13, 2019 at 9:10
  • 1
    First, ensure that selectors are valid. Second, why double from and to variables? Commented Sep 13, 2019 at 9:32
  • @kirill.z I ensure that the selectors are valid. Also corrected the object names Commented Sep 13, 2019 at 11:13
  • @AbhijitD 1. try without build 2. try split actions with sleep() like (new Actions(driver)).clickAndHold(dragable).moveToElement(dropable) --> sleep() --> .release(dragable).build() --> sleep() etc. because too fast test execution. 3. try to use github.com/storenth/drag-mock Commented Sep 14, 2019 at 11:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.