1

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.

2

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")));
    actions.moveToElement(textbox);

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

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

See the reply in this thread for a starting point.

0

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

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

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

    @driver.find_element(how,what).click

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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