We can hover the mouse to a webElement using Actions Class of
org.openqa.selenium.iteractions packages.
For example:
This is our test case.
Hovering mouse over an element of a menu, it displays sub menu
We can use this class by Keyboard or mouse.
Methods:
Action
buid():Generates a composite action containing all actions, ready to be performed.
Actions
click():Clicks at the current mouse location.
Actions
Click(WebElement onelement):Clicks on the middle of the given element.
these are similar for
doubleClick() and
doubleClick(WebElement onelement).
Actions
dragAndDrop(WebElement source, WebElement target): A convenience method that performs click and hold at the location of the source element, moves to the location of the target element , then releases the mouse.
Actions
moveToElement(WebElement to element):Moves the mouse to the middle of the element.
perform():A convenience method for performing the actions without calling build() first.
Methods hover and click element