2

当启用“本机事件”时,在 Internet Explorer 上运行时,使用“操作生成器”将鼠标悬停在元素上似乎并不可靠。(Chrome 和 Firefox 完美运行)

在使用以下代码禁用“本机事件”时,鼠标操作(如将鼠标悬停在元素上)也开始在 Internet Explorer 中按预期工作。但是,当禁用“本机事件”时,许多其他事情都会停止工作(例如单击按钮)。

Capabilities.setCapability("nativeEvents", false);
driver = new RemoteWebDriver(new URL("http://localhost:5556/wd/hub"), Capabilities);

因此,是否可以在运行时切换 WebDriver 的“本机事件”设置,如下所示?

driver = new RemoteWebDriver(new URL("http://localhost:5556/wd/hub"), Capabilities);
.
.
driver.setCapability("nativeEvents", false);
Perform Hover-over operations
driver.setCapability("nativeEvents", true);
Perform other operations
.
.
.
4

1 回答 1

4

不,您为 WebDriver 提供的功能是为该实例的生命周期设置的。

因此,当您愿意时,您无法更改它们。

于 2013-05-08T09:24:03.753 回答