我想使用 selenium 激活在 css 中定义的 :hover 类。这显然不是新的,但以前线程建议的所有方法都不再有效。
我认为我已经尝试过(未成功)
Selenium
-接口(interface)(使用WebDriverBackedSelenium
)和mouseOver
Actions
使用moveToElement(..).build().perform()
RenderedWebElement
自 2.20 以来已弃用,但我找不到它提供的hover()
方法的替代方法。
这次有什么办法吗? 谢谢!
最佳答案
试试这个由 Mark Collin 提到的解决方案 here .为我工作..
Locatable hoverItem = (Locatable) driver.findElement(By.xpath("//a[contains(text(),'Appliances')]"));
Mouse mouse = ((HasInputDevices) driver).getMouse();
mouse.mouseMove(hoverItem.getCoordinates());
关于java - css hover with selenium 2.20+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10331519/