how to set socks5 proxy with a FirefoxDriver for selenium2

4,743 views
Skip to first unread message

xcoder

unread,
Apr 13, 2012, 2:46:43 AM4/13/12
to Selenium Users
I've been googling for hours, but unable to find a way to set socks5
proxy with selenium2 FirefoxDriver. Can anyone please help me?

Nitin

unread,
Apr 13, 2012, 3:32:53 AM4/13/12
to Selenium Users
 FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("network.proxy.http", "62.201.209.16");
        profile.setPreference("network.proxy.http_port", 8080);
WebDriver driver = new FirefoxDriver(profile);
        driver.get("http://google.com");

When I open about:config in Firefox it says the proxy is set, but when I open any webpage say whatismyip.com it still says that my IP hasn't changed. Can anyone please tell me why is this happening? Even after setting proxy the browser is not taking that into account.

On Fri, Apr 13, 2012 at 12:16 PM, xcoder <nitin.co...@gmail.com> wrote:
I've been googling for hours, but unable to find a way to set socks5
proxy with selenium2 FirefoxDriver. Can anyone please help me?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.




--
Regards
Nitin
XCoderZ~~

Luke Inman-Semerau

unread,
Apr 13, 2012, 3:36:45 AM4/13/12
to seleniu...@googlegroups.com
This is how you should be doing it instead:

Nitin

unread,
Apr 13, 2012, 3:37:33 AM4/13/12
to seleniu...@googlegroups.com
But I have to set SOCKS5 proxy, and there isn't a method for that. 

Luke Inman-Semerau

unread,
Apr 13, 2012, 3:40:46 AM4/13/12
to seleniu...@googlegroups.com
as a shot in the dark, try setting "network.proxy.socks" and "network.proxy.socks_port"

Luke Inman-Semerau

unread,
Apr 13, 2012, 3:41:19 AM4/13/12
to seleniu...@googlegroups.com
(really one needs to take a look at firefox internals to see what it should be named)....

Nitin

unread,
Apr 13, 2012, 3:42:58 AM4/13/12
to seleniu...@googlegroups.com
Finally I found it, here's how to do it :
FirefoxProfile profile = new FirefoxProfile();
//        profile.setPreference("network.proxy.http", "62.26.x.y");
//        profile.setPreference("network.proxy.http_port", 8078);
        profile.setPreference("network.proxy.socks", "190.x.y.z");
        profile.setPreference("network.proxy.socks_port", 8**8);

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

        WebDriver driver = new FirefoxDriver(profile);
        driver.get("http://google.com");

Mike A

unread,
Mar 4, 2014, 12:08:22 PM3/4/14
to seleniu...@googlegroups.com
Can I ask what server software you use for your socks proxy?  I'd like to set one up on a linux/debian machine for proxying selenium firefox traffic.
Reply all
Reply to author
Forward
0 new messages