so cal cheesehead
so cal cheesehead

Reputation: 2573

How to mouseover and hold

Since upgrading to firefox 19 my tests broke where I need to hover over a link to display a submenu. Prior to firefox 19 the following worked like a charm:

    /*
    * Hover over column header
    */
    WebElement columnsRoot = driver.findElement(By.xpath(COLUMNS_ROOT_XPATH));
    WebElement firstColumn = columnsRoot.findElement(By.xpath("./td[1]/div"));
    Actions builder = new Actions(driver);
    builder.moveToElement(firstColumn).build().perform();

    /*
     * Click on dropdown button after it appears
     */
    WebElement dropdown = columnsRoot.findElement(By.xpath("./td[1]/div/a"));
    dropdown.click();
    Thread.sleep(500);

    /*
     * Hover over columns menu
     */
    String columnsMenuXpath = "(//div[@class=\" x-ignore x-menu x-component\"]//a)[3]";
    WebElement columnsMenu = driver.findElement(By.xpath(columnsMenuXpath));
    builder.moveToElement(columnsMenu).build().perform();

After hovering over the columns menu above a submenu would appear with a list of columns through which I would iterate to display. After I upgraded to Firefox 19 the submenu in the last step appears only momentarily then disappears which causes a bunch of NoSuchElementException exceptions, obviously because the submenu is not there and I'm still trying to click on something.

I tried after hovering over the menu to use another action to move over to an item in the submenu hoping that would keep the submenu open but no such luck.

Has anyone else ran into this issue? If so, is there a workaround or something?

I'm using selenium 2.31.0 which I upgraded to today from 2.28.0 due to incompatibility issues with Firefox 19.

Upvotes: 1

Views: 1229

Answers (1)

so cal cheesehead
so cal cheesehead

Reputation: 2573

Found a workaround and that was to move over to the next submenu but instead of using moveToElement(webelement) which is what someone else suggested but wasn't working for me. What did work for me was to use the method moveByOffset(int x, int y). So after hovering over the link that would display the sub-menu I did:

Actions movePointerRight = new Actions(driver);
movePointerRight.moveByOffset(100, 0).build().perform();

That seems to have gotten me past my issue for the time being but I would still be interested to know what others have come up with.

Upvotes: 1

Related Questions