testing
testing

Reputation: 1796

mouse hover action in selenium WebDriver

I want to know how to do do mouse hover action in selenium Web Driver.

The mouse hover action need to perform on tab. It need to hover then it need to click the tab. How can i do this using JavaScript executor and java.

Upvotes: 0

Views: 2085

Answers (2)

Sathish D
Sathish D

Reputation: 5034

Here is an example:

Actions act = new Actions(driver);

WebElement parentMenu = driver.findElement(By.xpath("Xpath"));
//Move to the element
act.moveToElement(parentMenu).build().perform()

Upvotes: 0

Akbar
Akbar

Reputation: 1525

Javascript executor should be the last resort to perform any action with Selenium. Selenium provides an Action class using which you can perform mouse/keyboard actions. For your scenario,

Actions builder = new Actions(driver);   
Action hoverAndClick = builder.moveToElement(webElement).click(webElement).build();
hoverAndClick.perform();

Upvotes: 2

Related Questions