硒与代理身份验证是可能的吗?

时间:2019-04-09 10:21:00

标签: authentication selenium-webdriver proxy

我正在尝试使硒代码与需要身份验证和用户名/密码的代理一起使用。

但是我到处搜索但找不到解决方案。 例如使用Firefox:

    def profile = new FirefoxProfile();
    profile.setPreference("network.proxy.type", 1);
    profile.setPreference("network.proxy.http", "<proxy>")
    profile.setPreference("network.proxy.http_port", <port>);
    options.setProfile(profile);
    driver = new FirefoxDriver(options)

我尝试过: profile.SetPreference(“ network.proxy.http”,“ http:// \:@:”);

与其他浏览器CHrome,IE相同。 那有可能吗?

        String PROXY = "<proxy>:<port>"
        Proxy proxy = new Proxy()
        proxy.setProxyType(Proxy.ProxyType.MANUAL)
        proxy.setHttpProxy(PROXY)
        proxy.setSslProxy(PROXY)


        proxy.setSocksProxy(PROXY)
        proxy.setSocksVersion(5)
        proxy.setSocksUsername("<someDOmain>\<user>")
                proxy.setSocksPassword("<pwd>")

        options.setCapability(CapabilityType.PROXY, proxy)

OR

        def profile = new FirefoxProfile();
        profile.setPreference("network.proxy.type", 1);
        profile.setPreference("network.proxy.http", "<proxy>")
        profile.setPreference("network.proxy.http_port", <port>);
        options.setProfile(profile);
        driver = new FirefoxDriver(options)

                profile.SetPreference("network.proxy.http", "http://<someDOmain>\<user>:<pwd>@<proxy>:<port>");

我希望代理使用用户名/ pwd。

感谢您的输入。

0 个答案:

没有答案