3

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!

1

1 Answer 1

-1

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://[email protected]:[email protected] will work, OR you can use AutoIT

2
  • When it was a long long time ago but AutoIT was the only option that actually worked.
    – Arik G
    CommentedMay 4, 2016 at 11:27
  • Are you sure that proxy is using in that case?
    – Maksym
    CommentedAug 12, 2016 at 20:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.