2

When I navigate to my url on chrome, I get The system cannot find the file specified." . I thought it might be due to automatic proxy settings on chrome. I want to explicitly turn off the proxy setting before starting chrome browser in selenium. I tried below, it isn't working. Can anyone help me

ChromeOptions options = new ChromeOptions();
DesiredCapabilities dc = DesiredCapabilities.chrome();
dc.setCapability("chrome.setProxyByServer", false);
System.setProperty("webdriver.chrome.driver",sChromeDriverPath);
WebDriver driver = new ChromeDriver();

No errors are thrown at any point of time but URL doesn't open up

Tia Anjana

1 Answer 1

3

You need to pass the options object to the chrome driver when you initialize it. If you use a specific capability then pass it to the chromeDriver(), so that chrome knows what to start with. Also there is no JSON object as setProxyByServer in chrome, instead use noProxy JSON object. Check this out. Here's how -

Proxy proxy=startProxy();
proxy.setProxyType(ProxyType.MANUAL); 
proxy.setNoProxy("");
ChromeOptions options = new ChromeOptions();
DesiredCapabilities dc = DesiredCapabilities.chrome();
dc.setCapability(CapabilityType.PROXY, proxy);
System.setProperty("webdriver.chrome.driver",sChromeDriverPath);
dc.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(dc);

More info about chrome capabilities. Hope it helps.

Sign up to request clarification or add additional context in comments.

2 Comments

How silly? Didn't notice that actually. Thanks for pointing it out.But unfortunately problem is still not solved.
@Anjana thats because there is no setProxyByServer on chrome object as and its used for IE browser only. Instead use the noProxy JSON object available. Updated code with that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.