Mouse Hover Actions Using Actions Class In Selenium

Mouse Hover Actions Using Actions Class:

Sometimes, sub menu items render in DOM only when we mouse hover on main menu. In that case, we face difficulty to click on sub menu item. In order to perform mouse hover actions, we need to chain all of the actions that we want to achieve in one go. To do this we need to make the driver move to the parent element that has child elements and click on the child element.

To achieve this we use Actions class in Selenium WebDriver.

Must Read: Actions Class in Selenium WebDriver

Create object of an Actions Class by passing the WebDriver instance. With the object of the Actions class, driver moves to the main menu and then to the sub menu and click on it.

Let’s see some scenarios.

Mouse hover actions on an element using Actions Class:

Mouse hover actions on a sub-element using Actions Class:

If we want to click on the sub-element, first we need to mouse hover on the parent-element and then sub-element and click on it.


If you are not regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

Get our latest blog posts delivered to your inbox

Subscribe and get popular blog posts about software testing industry.


4 thoughts on “Mouse Hover Actions Using Actions Class In Selenium”

  1. How to handle dynamic values in selenium

  2. Hi Menus like,

    In your website “”

    Go to tutorials –> Selenium —> Jenkins

    i want to click on jenkins.

    then how should i write the code?

    • Hi Prasanthi,
      try this out..

Leave a Comment

Share via
Copy link
Powered by Social Snap