Selenium中的代理身份验证弹出窗口

问题描述 投票:4回答:1

我正在开发一个需要使用代理的项目。我正在使用Chrome浏览器,当我运行脚本时,它会强制我输入代理的用户名和密码。

我已经尝试使用URL本身传递用户名和密码,但它无法正常工作。

这是代码:

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");
java selenium testing selenium-webdriver selenium-chromedriver
1个回答
1
投票

有一个小的Chrome插件,你可以手动建立from this answer。 要在java上下文中应用插件:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addExtensions(new File("proxy.zip"));
driver = new ChromeDriver(chromeOptions);   
© www.soinside.com 2019 - 2024. All rights reserved.