Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver - How to set proxy to "auto-detect" for Firefox

My scripts are running fine on chrome and IE but won't start on firefox due to firefox having "manual" set for its proxy settings. How can I set this to "auto-detect"?

Source code in C# please.

Thanks

like image 987
automationguy Avatar asked Dec 30 '25 01:12

automationguy


1 Answers

You don't have to set firefox to auto-detect. go to http://wpad/wpad.dat, it will return the javascript file which set up the proxy. You can find the proxy address inside. Then use the following code to do the trick

FirefoxProfile profile = new FirefoxProfile();
            String PROXY = "xx.xx.xx.xx:8080";
            OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
            proxy.HttpProxy=PROXY;
            proxy.FtpProxy=PROXY;
            proxy.SslProxy=PROXY;
            profile.SetProxyPreferences(proxy);
            FirefoxDriver driver = new FirefoxDriver(profile);
like image 161
zhouyu Avatar answered Dec 31 '25 16:12

zhouyu