I just want to automate mouse hover function for my project the scenario is

Scenario : There is a text box, if i hover on it,the edit icon will enable and i have to click that icon.

3 Answers 3


To perform a 'mouse hover' action, you need to concatenate all of the actions that you want to achieve in one go.

With the actions object you should first move to the text box, and then move to the edit icon and click it.

Below is my attempt at sample code to perform Mouse hover;

//Move to the Textbox    
Actions actions = new Actions(driver);
    WebElement textbox = wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("textbox")));

//Wait for the edit button to become available then click it    
    WebElement editButton = wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("editButton")));

To simulate complex (mouse) actions rather than working on the elements directly, use ActionBuilder.

See the reply in this thread for a starting point.


Assume that your text box has an ID eg: app_title, you can hover over it using

    element = @driver.find_element(:id,"app_title")

This will place the mouse focus on the textbox and you will see your edit icon on the screen. After that it is simple, you can click on it using


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.