0
votes

I'm working on automation project work using Selenium tool. I am trying to achieve the Drag&Drop concept in Web application, having difficulty to drop the object into the Destination (Drop location). The following piece of code used to achieve this:

Actions action = new Actions(driver);
Actions actions = new Actions(driver);
WebElement Destination = driver.findElement(By.xpath("html/body/div[1]/div/div/div[4]/div/div/ul"));
action.moveToElement(element);
action.build().perform();
action.clickAndHold(element).moveToElement(Destination).release(Destination).build();
actions.perform();

I'm not supposed to use "move offset"option.

Could you please help me to resolve this issue (or) any suggestions to achieve this?

1

1 Answers

0
votes

From the documentation drag-and-drop

You could do something like this:

Actions actions = new Actions(driver);
WebElement element = driver.findElement(By.name("source")); //source
WebElement Destination = driver.findElement(By.xpath("html/body/div[1]/div/div/div[4]/div/div/ul")); //target
actions.dragAndDrop(element, Destination).perform();

What is your "element" in your code? I can imagine is the "source" element.