How do I Autodetect firefox with Selenium webdriver in c# (Visual Studio)

Asked

Viewed 514 times

1

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

I managed to do with java, but here you have, things we already know, the company’s demands to do with c# in the Visual Studio.

Follow Code made in Selenium 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;
       }
    }
  }
}
  • GIVE more information, show how you did in Java.

  • proxy.setProxyType(Proxytype.AUTODETECT); ---> Disregard **

1 answer

1

Solved, goes to C#:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.