如何使用selenium internetexplorerdriver与代理c#

时间:2015-03-04 01:03:23

标签: c# selenium proxy

此代码有效:

        var ieOptions = new InternetExplorerOptions();
        ieOptions.ForceCreateProcessApi = true;
        ieOptions.BrowserCommandLineArguments = "-private";
        Proxy proxy = new Proxy()
        {
            Kind = ProxyKind.Manual,
            HttpProxy = "1.1.1.1:8080",
            SslProxy = "1.1.1.1:8080",
        };
        ieOptions.Proxy = proxy;
        IWebDriver driver = new InternetExplorerDriver(ieOptions);

此代码不会:

        var ieOptions = new InternetExplorerOptions();
        ieOptions.ForceCreateProcessApi = true;
        ieOptions.BrowserCommandLineArguments = "-private";
        Proxy proxy = new Proxy()
        {
            Kind = ProxyKind.Manual,
            SocksProxy = "1.1.1.1:1080",
        };
        ieOptions.Proxy = proxy;
        IWebDriver driver = new InternetExplorerDriver(ieOptions);

检查IE设置和袜子根本就没有填充。 这是一个错误吗?

1 个答案:

答案 0 :(得分:1)

我相信你错过了

options.UsePerProcessProxy = true;
options.Proxy = proxy;
IWebDriver driver = new InternetExplorerDriver(options);

强制webdriver使用proxy

第二段代码不会告诉浏览器在任何地方使用代理。如果您没有指定,driver将如何知道?

相关问题