How do I autodetect firefox with Selenium webdriver in C # (Visual Studio)

1

I need to select Autodetect of Firefox profile before running my script , because in the network settings of the browser is coming how to use system settings. That way I can not even open the system.

I was able to do with java , but here you have, things that we already know, company requirements to do with c# no Visual Studio .

Follow Selenium Code WEBDriver Java:

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.Proxy.ProxyType;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestesdeLayoutdeTelaSimulacaoEscolhadePlanoPortal {

      private static ArrayList<String> urlList = new ArrayList<String>();

       @BeforeClass
       public static void setup() {

           urlList.add("http://satktsao02web01:8085/front-sales/#/simulation");
       }

 @Test
       public void passTraffixThroughProxyTest() {
 DesiredCapabilities capability = new DesiredCapabilities();
           addProxyCapabilities(capability);

           for (@SuppressWarnings("unused") String url : urlList){
               WebDriver driver = new FirefoxDriver(capability);
               driver.get("http://satktsao02web01:8085/front-sales/#/simulation");
               driver.manage().window().maximize();
                  public static DesiredCapabilities addProxyCapabilities(DesiredCapabilities capability) {
           Proxy proxy = new Proxy();
           **proxy.setProxyType(ProxyType.AUTODETECT);**

           capability.setCapability(CapabilityType.PROXY, proxy);
           capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
           return capability;
       }
    }
  }
}
    
asked by anonymous 08.09.2015 / 17:32

1 answer

1

Solved, go to C# :

var ff = new FirefoxProfile();
ff.SetPreference("network.proxy.type", (int)ProxyKind.AutoDetect);
var driver = new FirefoxDriver(ff);
    
08.09.2015 / 19:11