我一直在尝试使用 Selenium WebDriver 和 Firefox 19 在我的网页中测试工具提示。
我基本上是在尝试使用鼠标操作将鼠标悬停在附加了工具提示的元素上,以测试工具提示是否显示,并将鼠标悬停在另一个元素上以测试工具提示是否隐藏。
第一个操作工作正常,但将鼠标悬停在另一个元素上时,工具提示仍然可见。手动测试网页时不会出现此问题。
有没有其他人遇到过这个问题?我正在使用 Ubuntu 12.04。
最佳答案
Advanced Actions API 似乎依赖于 native 事件,这些事件在 Linux 版本的 Firefox 中默认被禁用。因此,必须在 WebDriver 实例中显式启用它们。
FirefoxProfile profile = new FirefoxProfile();
//explicitly enable native events(this is mandatory on Linux system, since they
//are not enabled by default
profile.setEnableNativeEvents(true);
WebDriver driver = new FirefoxDriver(profile);
另外,就我而言,我需要将 WebDriver 升级到版本 2.31,因为 hover(moveToElement
) 操作在 2.30 上无法正常工作,即使显式启用了 native 事件也是如此。在 Linux 上使用 WebDriver 版本 2.31 和 Firefox 版本 17 和 19 对此进行了测试。
欲了解更多信息,您可以查看此链接:
http://code.google.com/p/selenium/wiki/AdvancedUserInteractions#Native_events_versus_synthetic_events
关于java - Selenium WebDriver 鼠标操作 moveToElement 不会在 Firefox Linux 上引发 mouseout 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15073351/