Kirill KZ February 2016

Firefox webdriver with socks aren't work. What's wrong?

I have trubs with my code. I bought list of proxy. Name is "List of SOCKS 4/5 proxies with a binding to IP address" and it everyhour is update. So, I take first line from this txt file, paste into my code, but isn't work! Code is:

        FirefoxProfile profile = new FirefoxProfile();
        profile.SetPreference("network.proxy.socks", "46.161.62.165");
        profile.SetPreference("network.proxy.socks_port", 1085);

        profile.SetPreference("network.proxy.type", 1);         // this is used to set proxy configuration to manual, after which firefox considers the //proxy set above

        FirefoxDriver driver = new FirefoxDriver(profile);
        driver.Navigate().GoToUrl(@"http://whatismyipaddress.com");

Also I tried another way:

    FirefoxProfile profile = new FirefoxProfile();
    String PROXY = "46.161.62.165:1080";
    OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
    proxy.SocksProxy = PROXY;
    profile.SetProxyPreferences(proxy);
    int timeoutSeconds = 1800;
    FirefoxDriver Driver = new FirefoxDriver(new FirefoxBinary(), profile, new TimeSpan(0, 0, 0, timeoutSeconds));
    Driver.Navigate().GoToUrl(@"http://whatismyipaddress.com");

BUT IT DOESN'T WORK. Please, help me. Some interesting fact: this proxy real and it's should work. Also I have another lists. There are:

List of HTTP/HTTPS proxies with authentication by password:
TXT  CSV
List of SOCKS 4/5 proxies with authentication by password:
TXT  CSV
List of HTTP/HTTPS proxies with a binding to IP address:
TXT  CSV
List of SOCKS 4/5 proxies with a binding to IP address:

How I can do it with login and password? Thanks for all and everyone. Peace.

Answers


Kim Homann February 2016

I haven't used SOCKS, but I think it should look like this:

private FirefoxDriver _CreateFirefoxDriver(string socksProxy)
{
    if (string.IsNullOrEmpty(socksProxy))
    {
        return new FirefoxDriver();
    }

    var caps = new DesiredCapabilities();
    caps.SetCapability(CapabilityType.Proxy, new Proxy { SocksProxy = socksProxy });
    return new FirefoxDriver(caps);
}


nilesh February 2016

Documentation shows it this way (This is java code but same applies to C#)

String PROXY = "46.161.62.165:1085";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setSocksProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);

Post Status

Asked in February 2016
Viewed 3,091 times
Voted 5
Answered 2 times

Search




Leave an answer