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", "my.email@website.com");
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://my.username@website.com:password@someWebsite.com
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 = "my.email@website.com" + ":" + "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!