-2

弹出窗口有“Welcome to IE8”消息、“Next”和“Ask me later”按钮。那么我如何使用 WebDriver 来处理这个问题呢?谢谢。

4

1 回答 1

2

这些设置可以通过注册表来控制。Selenium WebDriver 提供WindowsUtilsAPI 来操作 Windows 注册表。

根据How to Disable Internet Explorer 8 Welcome Screen (Tour and RunOnce) for All Users(我去年使用过的说明),必须设置以下注册表值:

=Value Name=                   =Data=   =Type=
IE8RunOnceLastShown            1        REG_DWORD
IE8RunOncePerInstallCompleted  1        REG_DWORD
IE8RunOnceCompletionTime       (empty)  REG_BINARY
IE8TourShown                   1        REG_DWORD
IE8TourShownTime               (empty)  REG_BINARY
IE8RunOnceLastShown_TIMESTAMP  (empty)  REG_BINARY

在 Java 代码中,它会是这样的:

import org.openqa.selenium.os.WindowsUtils;
...
    WindowsUtils.writeIntRegistryValue("IE8RunOnceLastShown", 1);
    WindowsUtils.writeIntRegistryValue("IE8RunOncePerInstallCompleted", 1);
    WindowsUtils.writeStringRegistryValue("IE8RunOnceCompletionTime", "");
    WindowsUtils.writeIntRegistryValue("IE8TourShown", 1);
    WindowsUtils.writeStringRegistryValue("IE8TourShownTime", "");
    WindowsUtils.writeStringRegistryValue("IE8RunOnceLastShown", "");
于 2013-07-03T10:15:46.020 回答