Drag and Drop not working..as my drag and drop area not having 'Frames' i didn't use switchTo() here.

    Actions action= new Actions(driver);


    WebElement drag= driver.findElement(By.xpath("//div[contains(text(),'GEO')]"));

    WebElement drop= driver.findElement(By.xpath("//div[@placeholder='Drag and Drop the subjects which needs evaluation.']"));



    action.dragAndDrop(drag, drop).perform();


Can anyone please help?

  • You are testing against Chromedriver? If so, try the same test(s) against Firefox. Chromedriver has a known issue with drag-and-drop and HTML5. My HTML5 related elements, I can only drag-n-drop in non-Chrome. github.com/SeleniumHQ/selenium/issues/6235 Commented Feb 23, 2019 at 18:56
  • I'm testing on firefox
    – Albin K S
    Commented Feb 24, 2019 at 5:33

4 Answers 4


You try using build() . Consider the example :

action.dragAndDrop(drag, drop).build().perform();


Try the below code :

new Actions(driver)
                .moveByOffset(2, 0)

Hope it'll resolve the issue

  • I tried both ways but doesn't worked for me
    – Albin K S
    Commented Feb 23, 2019 at 10:15
  • This answer should work but If its not work I added another answer for this method.
    – sayhan
    Commented Feb 26, 2019 at 15:24

Note: I am adding as an answer since I don't have enough reps to add comment. I will delete the answer if required once the requested change is made.

Albin, is it possible to share the URL where you are facing the issue so we can try ourselves?

Also, a small correction for @jatin khattar. Calling build() is not necessary when using perform(). perform() will call build() method internally. As per the java docs for [Actions][1] class:

void perform()

A convenience method for performing the actions without calling build() first.

Edit: Okay. Sharing the URL is not possible and its understandable. However, can you please share the behaviour when running the code? Any error messages? Or what is happening when the code is executed?

  • so sorry about the URL...it's our upcoming project so that I can't share with anybody..Is there anything else that I can do?
    – Albin K S
    Commented Feb 23, 2019 at 16:07

Can you please try following :

Actions builder = new Actions(driver);

    Action dragAndDrop = builder.clickAndHold(someElement)


In IT industry various software testing solutions are provided by companies depending on application behavior.

Below is one of the solution for DragandDrop issue w.r.t co-ordinates of webelement.

int sourceWidth = element.getSize().getWidth();
int SourceHeight = element.getSize().getHeight();
int destinationWidth = destElement.getSize().getWidth();
int destinationHeight = destElement.getSize().getHeight();
Actions act = new Actions(driver);
act.moveToElement(element, (sourceWidth / 2), SourceHeight / 2).clickAndHold().build().perform();
act.moveToElement(destElement, (destinationWidth / 2) , (destinationHeight / 2)).release().build().perform();

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.