I am trying to pass Selenium Chrome driver through a proxy server. The server uses username & password authentication.
When I try:
Proxy proxy = new Proxy(); proxy.setHttpProxy("12.345.678.9"); capabilities.setCapability("java.net.socks.username", "[email protected]"); capabilities.setCapability("java.net.socks.password", "my_password"); capabilities.setCapability(CapabilityType.PROXY, proxy); webDriver = new ChromeDriver(capabilities);
Then I try to get a website with .get() method but I get an alert requiring the proxies username and password.
I tried to use in the get(): http://[email protected]:[email protected]
But it did not work as well.
Also tried:
String stringUrl = "http://www.someUrl.com"; URL url = new URL(stringUrl); URLConnection uc = url.openConnection(); uc.setRequestProperty("X-Requested-With", "Curl"); String userpass = "[email protected]" + ":" + "my_password"; String basicAuth = "Basic " + new String(new Base64().encode(userpass.getBytes())); uc.setRequestProperty("Authorization", basicAuth); InputStreamReader inputStreamReader = new InputStreamReader(uc.getInputStream());
Any suggestions here?
Thanks guys!