如何使用WebDriver处理Internet Explorer启动消息?

时间:2013-07-03 09:31:58

标签: selenium webdriver selenium-webdriver

具有“欢迎使用IE8”消息,“下一步”和“稍后询问”按钮的弹出窗口。那我怎么能用WebDriver来处理呢?感谢。

1 个答案:

答案 0 :(得分:2)

可以通过注册表控制这些设置。 Selenium WebDriver提供了WindowsUtils API来操作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", "");