title: How to setup proxy for chrome in selenium : Java
body: <p>I have setup proxy for PhantomJS and verified the IP address using below code. It works fine. </p>
  
  <p>Here the Host name is IP address: 43.19.196.36</p>
  
  <pre><code>DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
  capabilities.setJavascriptEnabled(true);
  System.setProperty("phantomjs.binary.path", "../Drivers/phantomjs.exe");
  
  ArrayList&lt;String&gt; cliArgsCap = new ArrayList&lt;String&gt;();
  cliArgsCap.add("--proxy=hostname:port");
  cliArgsCap.add("--proxy-auth=username:password");
  cliArgsCap.add("--proxy-type=http");
  capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
  
  driver = new PhantomJSDriver(capabilities);
  
  driver.get("http://api.ipify.org/");
  logger.info("IP Address: " + Jsoup.parse(driver.getPageSource()).body().text());
  </code></pre>
  
  <p>This code works fine and my application is using proxy address.</p>
  
  <pre><code>2017-07-24 16:37:47 INFO  ElectoralRoll:81 - IP Address: 42.10.197.10
  </code></pre>
  
  <p>But, How to setup the same proxy for chrome? Here is my code. It prints my IP address. It is not using the proxy.</p>
  
  <pre><code>Proxy proxy = new Proxy();
  
  proxy.setHttpProxy("hostname:port");
  proxy.setFtpProxy("hostname:port");
  proxy.setSslProxy("hostname:port");
  proxy.setSocksUsername("username");
  proxy.setSocksPassword("password");
  
  capabilities.setCapability(CapabilityType.PROXY, proxy);
  </code></pre>
  
  <p>This prints my IP address:</p>
  
  <pre><code>2017-07-24 16:37:47 INFO  ElectoralRoll:81 - IP Address: 
  </code></pre>
  
  <p>I have also tried this. But did not work.</p>
  
  <pre><code>capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://username:password@hostname:port"));
  </code></pre>
  
  <p>Referred:
  <a href="https://stackoverflow.com/a/19225780/8329042">https://stackoverflow.com/a/19225780/8329042</a></p>
  
  <p>Edit: I have added: (@Riaz's answer)</p>
  
  <pre><code>proxy.setProxyType(ProxyType.MANUAL);
  </code></pre>
  
  <p>Using this in my code, it says:</p>
  
  <pre><code>2017-07-26 20:22:03 INFO  ElectoralRoll:83 - IP Address: proxy authorization required
  </code></pre>