Proxy authentication popup in Selenium

蓝咒 提交于 2021-01-27 07:41:03

问题


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");

回答1:


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);   


来源:https://stackoverflow.com/questions/51853219/proxy-authentication-popup-in-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!