How to perform mouseover function in Selenium WebDriver? (C#)

How to perform mouseover function in Selenium WebDriver? (C#)

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

IWebElement element = driver.FindElement(By.XPath("//strong[text()='English']"));
Actions action  = new Actions(driver);
action.MoveToElement(element).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.