我正在使用 Firefox 19.0.2、Selenium 2.31.2.0
在设置方法中,我通过 firefox 配置文件 firefoxProfile.SetPreference("dom.disable_open_during_load", true); 此选项是必需的,因为客户希望在启用弹出阻止的情况下一切正常。
在测试中,我需要将内容分享给外部社区。当我按下按钮时,会出现外部社区弹出窗口。问题是当我手动执行此操作时,一切正常并且弹出窗口不会阻塞。当我尝试通过 WebDriver 单击此按钮时,Firefox 会阻止弹出窗口。
像这样点击按钮:
//kind of mouse over emulation
new Actions(Driver).MoveToElement(_element).Release(_element).Build().Perform();
_element.Click();
我认为问题在于本机按钮单击和 WebDriver 执行的单击之间的差异。在 Firefox 配置文件中设置EnableNativeEvents = true
不是解决方案,因为测试变得非常不稳定。
也许有人面临这个问题并可以提供解决方案。