I am trying to mouse hover on image to display menu list.
My HTML
code is:
<img id="logo" src="/web/images/header/img_Logo_Topbar.png">
But I am trying Xpath as "//*[@id='logo']"
. There is no response.
I am using this script:
Actions a1 = new Actions(driver);
a1.moveToElement(driver.findElement(By.xpath("//*[@id='logo']")))
.build()
.perform();
Thread.sleep(1000L);
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);