Selenium - 无法将鼠标悬停在 Firefox 上

Selenium - Unable to mouse over with Firefox

有没有人找到解决以下问题的鼠标悬停在 Firefox 元素上的解决方法?

org.openqa.selenium.UnsupportedCommandException: mouseMoveTo
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

该命令适用于 Edge、IE、Chrome。

我使用的是最新的 geckodriver (0.18.0) 和 Firefox (54.0.1)

我可以看到为此打开了一个错误。 https://github.com/SeleniumHQ/selenium/issues/4008

但是,作为解决方法,您可以尝试更改 geckodriver 或 Firefox 版本。如果这是不可能的,你总是可以使用 javascript 滚动到元素。

je.executeScript("arguments[0].scrollIntoView(true);",element);

然而,这只会将元素放入视口。它不会将鼠标放在元素上。因此,如果您感兴趣,它不会生成任何 Mouseoever 事件。

原因很简单,鼠标移动是由你OS而不是JavaScript控制的。这是为了安全而设计的。