How to do mouse hover using Selenium WebDriver in Firefox 19?

后端 未结 6 700
梦谈多话
梦谈多话 2020-12-14 10:14

I have used selenium 2.31.

I have used Actions class for mouse movement. Using this I moved the mouse over a menu and its submenu appeared only for a fraction of se

6条回答
  •  猫巷女王i
    2020-12-14 10:29

    With the actions object you should first move the menu title, and then move to the popup menu item and click it. Don't forget to call actions.perform() at the end. Here's some sample Java code:

    Actions actions = new Actions(driver);
    WebElement menuHoverLink = driver.findElement(By.linkText("Menu heading"));
    actions.moveToElement(menuHoverLink);
    
    WebElement subLink = driver.findElement(By.cssSelector("#headerMenu .subLink"));
    actions.moveToElement(subLink);
    actions.click();
    actions.perform();
    

提交回复
热议问题