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.

Or

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.

mouse hover actions

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

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 “https://www.softwaretestingmaterial.com/mouse-hover-actions-using-selenium/”

    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