6

I am working on a project where I need to use a proxy. I am using the Chrome browser and when I run my script it forces me to enter the username and password of the proxy.

I have tried passing the username and password with the URL itself, but it is not working.

Here is the code:

Proxy p = new Proxy();
p.setHttpProxy("in-pr.oxylabs.io:20000");
p.setSslProxy("in-pr.oxylabs.io:20000");
System.setProperty("webdriver.chrome.driver","D:\\Love_Testing\\Senium_Naveen\\chrome Driver\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
//  options.addArguments("--incognito");
DesiredCapabilities dc = DesiredCapabilities.chrome();
dc.setCapability(ChromeOptions.CAPABILITY,options);
dc.setCapability("proxy",p);
WebDriver driver = new ChromeDriver(dc);
driver.get("https://www.google.com");
DaveyDaveDave
  • 9,821
  • 11
  • 64
  • 77
Love
  • 125
  • 2
  • 13

1 Answers1

2

There's a small Chrome plugin that you can build manually from this answer.
To apply the plugin, in a java context:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addExtensions(new File("proxy.zip"));
driver = new ChromeDriver(chromeOptions);   
dlauzon
  • 1,241
  • 16
  • 23