How to set Proxy setting for Chrome in Selenium Java

前端 未结 2 824
太阳男子
太阳男子 2020-12-10 13:34

I am able to set proxy settings for Firefox as below.

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setProxyType(ProxyType.MANUAL)         


        
相关标签:
2条回答
  • 2020-12-10 13:39

    Try this code:

    FirefoxProfile profile = new FirefoxProfile(); 
    
    profile.setPreference("network.proxy.type", ProxyType.AUTODETECT.ordinal()); 
    
    WebDriver driver = new FirefoxDriver(profile);
    

    here we have one more solution....it's worked for me

    0 讨论(0)
  • 2020-12-10 13:51

    You can try using the DesiredCapabilities class, like this:

    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://user:password@proxy.com:8080"));
    WebDriver driver = new ChromeDriver(capabilities);
    
    0 讨论(0)
提交回复
热议问题