I want to set up a proxy which require authentication. I have used proxy object and option.setProxy()
but i'm am still prompted with authentication window.
When I specify in the proxy url ( username:pwg@ip:port
) then the proxy is not taken into account at all (checked with Wireshark).
This is my code :
int randomProxy = ThreadLocalRandom.current().nextInt(0, proxies.length);
String PROXY = String.format("******:******@%s:*****",proxies[randomProxy]);
System.out.println(PROXY);
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
proxy.setSocksUsername("******");
proxy.setSocksPassword("******");
System.setProperty("webdriver.chrome.driver","/var/chromedriver/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setProxy(proxy);
int randomAgent = ThreadLocalRandom.current().nextInt(0, userAgents.length);
options.addArguments(userAgents[randomAgent]);
this.driver = new ChromeDriver(options);
This is how I set my proxy:
capabilities = DesiredCapabilities.chrome();
Proxy proxy = new Proxy();
proxy.setHttpProxy(proxyHost + ":" + proxyPort);
capabilities.setCapability("proxy", proxy);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.