Mouse Hover and Drag Drop Action in Selenium WebDriver
Posted By : Neha Dahiya | 28-May-2018
Mouse Hover:
Special mouse and keyboard events can be handled using Advanced User Interactions API which contains Action class needed to execute these events.
Firstly we have to identify elements which we want to hover and then with the help of Action class, move over an element action can be performed.
Step 1: Import the Actions class.
import org.openqa.selenium.interactions.Actions;
Step 2: Instantiate a new Actions object.
Actions act = new Actions(driver);
Step 3: Use perform() method which is used to execute the action.
Actions act = new Actions(driver);
act.moveToElement(element).perform();
Find the code below to perform Mouse over an element.

Drag and Drop:
A predefined method dragAndDrop(source, destination), a method of Actions class.
Step 1: Find XPath of both source and destination.
Step 2: Use perform() method which is used to execute the action.
Find the code below to perform Drag and Drop Action
Thanks!!
More From Oodles
Rajat Maan | 27-Dec-2022
Mohd Nawaz Hussain | 27-Dec-2022
Mohd Nawaz Hussain | 31-Oct-2022
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Neha Dahiya
Neha is a bright QA Engineer with skills in manual testing . Apart from finding bugs in application, she loves sketching and painting.