0

Currently working in Selenium WebDriver and using Java. I want to perform the action as mouse hover to the tab and it need to click the tab. Here in this code i can able to identify the element and it is opening the tab. But the problem is it is not mouse hovering and not clicking, it is directly opening the page.

 JavascriptExecutor executor = (JavascriptExecutor)driver;
         executor.executeScript("arguments[0].click();",                                                     
driver.findElement(By.id("ext-pr-backlog-evolution") ));

If i use the

WebElement menuHoverLink = driver.findElement(By.id("ext-pr-backlog-evolution"));
actions.moveToElement(menuHoverLink).click().perform();

It is not exactly finding the element and it is clicking some other tab. so i want to mouse hover in javascript executor.

1
  • Please suggest any sample method to fix this issue Commented Jan 27, 2014 at 5:23

1 Answer 1

3

You can create a mouse event

document.createEvent('MouseEvents');

then assign a mouse hover to it

mouseEventObj.initEvent( 'mouseover', true, true );

and then dispatch it

element.dispatchEvent(mouseEventObj);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.