kurri kurri - 7 months ago 39
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);


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);