Drag and Drop Action in Selenium webdriver using Actions class

Hello Welcome to the new post of Selenium, in this post, we will see how to perform Drag and drop in Selenium webdriver.

All application which is available on the web  like all E-commerce like Flipkart, Amazon, Snapdeal they have all advanced activities for example mouse hover, drag and drop and right click etc. In these cases, we will use Actions class in Selenium.

Drag and Drop in Selenium webdriver

For all advance activity in Selenium Webdriver, we can perform easily using Actions class like Drag and Drop, mouse hover, right click, Click and Hold and so on.
We have predefined method called dragAndDrop(source, destination) which is a method of Actions class.

Approach- Find the xpath of the Source  and find the xpath of destination.

Both source and destination in form of WebElement.

Note- Any method of Actions class we need to call perform () method otherwise we will get an exception. If we have series of action in our script using Actions class then we have to call build().perform() method.


For the demo, I will be using below site. http://jqueryui.com/resources/demos/droppable/default.html


Drag and drop in Selenium webdriver


We can also perform drag and drop using x and y coordinate but this will be only applicable when destination is not given.

Thanks for visiting my blog. Please comment below if you are finding any issue.

Keep in touch. Have a nice day 🙂


Now if you are comfortable with Basic Selenium, you can check out Advance Selenium Tutorial as well. 🙂

For More updates Learn Automation page

For any query join Selenium group- Selenium Group


  1. Alam
  2. Sarayu
  3. Kavitha
  4. Surya
  5. Stella
  6. Amogh
  7. Sonia
  8. Palash
  9. Suresh Sharma