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());
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.