几次成功尝试后,未指定Selenium中IE的代理

时间:2019-05-10 08:07:09

标签: c# selenium internet-explorer selenium-webdriver proxy

也许有人可以说出为什么经过约50次测试后IE停止代理。首先,一切正常,代理已成功安装。

Selenium独立服务器3.141.59 Internet Explorer驱动程序服务器x64 3.141.59(x32相同)

也许在此post中描述了我的问题?如果是,如何释放全局挂钩?

我查看了驱动程序日志,很可能是这样的错误:

T 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\proxymanager.cpp(97) ProxyManager::SetProxySettings
D 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\proxymanager.cpp(100) Setting proxy for individual IE instance.
T 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\proxymanager.cpp(244) ProxyManager::SetPerProcessProxySettings
T 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\proxymanager.cpp(147) ProxyManager::BuildProxySettingsString
D 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\proxymanager.cpp(180) Built proxy settings string: ‘http=localhost:6666 ftp=localhost:6666 https=localhost:6666’
T 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\hookprocessor.cpp(105) Entering HookProcessor::Initialize
T 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\hookprocessor.cpp(164) Entering HookProcessor::InstallWindowsHook
W 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\hookprocessor.cpp(187) [Windows Error 126]: Unable to set windows hook
T 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\hookprocessor.cpp(258) Entering HookProcessor::PushData
W 2019-05-04 15:21:59:208 c:\projects\webdriver\cpp\iedriver\hookprocessor.cpp(260) No hook procedure has been set

据我了解,WindowsHook停止工作,但是为什么以及如何修复它?

public override IWebDriver CreateRemoteDriver() {
    var options = GetOptions();

    return new RemoteWebDriver(new Uri(GridUri), options.ToCapabilities(), CommandTimeout);
}

public InternetExplorerOptions GetOptions() {
    InternetExplorerOptions options = new InternetExplorerOptions {
        IntroduceInstabilityByIgnoringProtectedModeSettings = true,
        InitialBrowserUrl = "about:blank",
        EnableNativeEvents = true,
        EnsureCleanSession = true,
        EnablePersistentHover = false,
        UsePerProcessProxy = true,
        ForceCreateProcessApi = true,
        BrowserCommandLineArguments = "-private"
    };

    var str = GetStrategyValueOrNull();
    if (str != null) options.AddAdditionalCapability(PageLoadStrategyCapabilityName, str);

    foreach(var capability in CapabilityProperties) {
        options.AddAdditionalCapability(capability.Name, capability.Value);
    }

    var proxy = GetProxy();

    if (proxy != null) {
        options.Proxy = GetProxy();
    }
    return options;
}

public Proxy GetProxy() {
    if (Proxy != null) {
        var proxy = new Proxy {
            Kind = ProxyKind.Manual,
            IsAutoDetect = false,
            HttpProxy = Proxy,
            SslProxy = Proxy,
            FtpProxy = Proxy
        };
        return proxy;
    }
    return null;
}

0 个答案:

没有答案