To carry out this task of mouse hovering over a web-element Selenium, we use the Actions class. The Actions class provided by Selenium Webdriver is used to generate complex user gestures including mouseover, right-click, double click, drag, and drop, etc.
Code snippet to mouseover
Actions action = new Actions(driver);
WebElement element = driver.findElement(By.id("elementId"));
action.moveToElement(element).perform();
Here, we are instantiating an object(named: action) of Actions class. After that, we pass the WebElement(located using id) to be mouse hovered as a parameter to the moveToElement() method present in the Actions class. Then, we will call the perform() method to perform the generated action.