How to perform mouseover function in Selenium WebDriver using Java?

How to perform mouseover function in Selenium WebDriver using Java?

To mouse over elements, you need to use the Actions class to build and perform the MoveToElement command.

WebElement englishButton = driver.findElement(By.xpath("//strong[text()='English']"));
Actions action = new Actions(driver);
action.moveToElement(englishButton).perform();

 

The Actions class allows you to perform more advanced actions that can more accurately resemble human interactions with the page. You can also use it to chain multiple commands together to be called in one line.

 

 

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.