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!
You can use
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/New User");
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);
For this, solution http://my.username@website.com:password@someWebsite.com will work, OR you can use AutoIT
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.