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
    – testing
    CommentedJan 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); 

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.