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 Feb 23 '19 at 18:56
  • I'm testing on firefox
    – Albin K S
    Feb 24 '19 at 5:33

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
    Feb 23 '19 at 10:15
  • This answer should work but If its not work I added another answer for this method.
    – slckayhn
    Feb 26 '19 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
    Feb 23 '19 at 16:07

Can you please try following :

Actions builder = new Actions(driver);

    Action dragAndDrop = builder.clickAndHold(someElement)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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