kurri kurri -4 years ago 156
Java Question

How to do Mouse hover on Image in selenium web driver to get menu list

I am trying to mouse hover on image to display menu list.


code is:

<img id="logo" src="/web/images/header/img_Logo_Topbar.png">

But I am trying Xpath as
. There is no response.

I am using this script:

Actions a1 = new Actions(driver);

Answer Source

It's looks like a bug, I'm not sure what is the solution for this but if you want alternate solution to perform mouse hover on element you can use JavascriptExecutor to as below :-

WebElement element = driver.findElement(By.id("logo"));

((JavascriptExecutor)driver).executeScript("var mouseEvent = document.createEvent('MouseEvents');mouseEvent.initEvent('mouseover', true, true); arguments[0].dispatchEvent(mouseEvent);", element);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download