Styrow.dev
Question 54 of 64

How to mouse hover on a web element using WebDriver?

Question

How to mouse hover on a web element using WebDriver?

Answer

We can use Actions class as below:

WebElement ele = driver.findElement(By.xpath(""xpath""));

//Create object ‘action’ of an Actions class

Actions action = new Actions(driver);

//Mouseover on an element

action.moveToElement(ele).perform();