4

I want to activate the :hover class defined in css using selenium. This isn't new obviously but all suggested methods by previous threads don't work anymore.

Thinks I have tried (unsuccessfully)

  • Selenium-Interface (using WebDriverBackedSelenium) and mouseOver
  • Actions using moveToElement(..).build().perform()
  • The RenderedWebElement is deprecated since 2.20 but I can't find a replacement for the hover() method it provided.

Any ideas how to do it this time? Thanks!

1 Answer 1

2

Try this solution which was mentioned by Mark Collin here. Worked for me..

Locatable hoverItem = (Locatable) driver.findElement(By.xpath("//a[contains(text(),'Appliances')]"));
Mouse mouse = ((HasInputDevices) driver).getMouse();
mouse.mouseMove(hoverItem.getCoordinates());
1
  • Thanks, that is even another method I didnt consider yet. The cause for this behavior however was that I disabled native events for my driver for former incompatibilities. After activating them again, all of the methods described actually work.
    – franz
    May 2, 2012 at 8:13

Your Answer

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

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