Uncheck Proxy Server Settings in Chrome Browser Using Selenium WebDriver

September 16, 2017
selenium How-to

If you have read my past posts, you might know that I follow a lot of forums to understand what type of issues are faced by the community. This helps me to broaden my knowledge. Couple of days ago, I stumbled upon this question on a such forum on Facebook.

Question was- “How to uncheck proxy server settings in chrome browser using selenium Code ?” with Below image.

That was really interesting question and Thanks for this question ‎Roby Chauhan.

Defining problem statement:- Uncheck proxy setting while invoking Chrome browser using Selenium WebDriver.

Understanding Problem Statement:-

I first tried to solve this question manually and realized once again that proxy setting that you applied in one browser are not just that browser specific but it OS specific.

That means if you set proxy in one browser it is applicable to all browsers. If you set wrong proxy in one browser you would not able to connect to the internet using any browser. Refer image below for more understanding. Image taken from Chrome support group for education and help.

So basically we are talking about this red box, where we doing some setting which we need to overcome while invoking chrome using Selenium WebDriver.

Solution:-

After a lot of searching on Google, I found solution somewhere on the internet, we need to below use Capabilities & ChromeOptions.

options.addArguments("--no-proxy-server");

Please check working code snippet below:-

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;

/**
 * Created by Amol Chavan on 9/10/2016.
 */

public class DriverFactory {
   public static WebDriver createInstance(){
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--no-proxy-server");
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        System.setProperty("webdriver.chrome.driver","C:\\Grid\\chromedriver.exe");
        WebDriver driver = new ChromeDriver(capabilities);
        driver.get("http://www.google.com");
        return driver;
    }
}

This is all for now.

Cheers!!

Highlight Element in Selenium WebDriver

August 29, 2017
selenium How-to

Open Browser in Incognito InPrivate in Selenium WebDriver

September 27, 2016
selenium How-to

Object Repository in Selenium WebDriver

July 11, 2016
selenium How-to