Mouse Hover

Mouse hover using javaScript Executor

In order to perform a 'mouse hover' action, we need to take the help of Selenium Actions class. Which we have seen earlier Mouse Hover with Actions class

Now in this tutorial, we will see how to perform mouse hover using JavaScript Executor We will look into the below example and understand how it is working.

Mouse Hover Actions in Selenium Webdriver

In order to perform a 'mouse hover' action, we need to chain all of the actions that we want to achieve in one go. So move to the element that which has sub elements and click on the child item. It should the same way what we do normally to click on a sub menu item.

With the actions object you should first move the menu title, and then move to the sub menu item and click it.

First we need to create new action builder instance by passing the webdriver instance, then.

Below is the sample code to perform Mouse hover action

Example 1: