I'm using capybara (2.6.2) to build an rspec-extension called proxy_rb to do TDD of our HTTP proxy environments. Setting the proxy without any proxy authentication works fine. Authentication against proxies using the BASIC-scheme does not work.
This is a followup to https://github.com/SeleniumHQ/selenium-google-code-issue-archive/issues/5209. Hope there's no other issue about this issue. I found none.
Selenium enters Username + Passwort for Proxy Authentication in Firefox.
Firefox shows Username + Passwort-Form which is closed after a short time span.
Having this same issue trying to add a proxy that requires authentication. I am utilizing Chrome but it still doesn't allow me to pass in a proxy with authentication.
Hi, I'm using chromedriver with selenium python. I still cannot find a way to correctly handle proxy authentication, and all the methods I find through googling fail on my case. Any suggestions?
I'm using geckodriver and also having issues when trying to use a proxy with basic auth.
This is using Firefox 58
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", ip)
profile.set_preference("network.proxy.http_port", port)
profile.set_preference("network.proxy.ssl", ip)
profile.set_preference("network.proxy.ssl_port", port)
credentials = '{}:{}'.format(proxy_info['username'], proxy_info['password'])
credentials = b64encode(credentials.encode('ascii')).decode('utf-8')
# b64 encode username and password as is required by the `Proxy-Authentication` header
profile.set_preference("extensions.closeproxyauth.authtoken", credentials)
2018, still facing proxy auth issues.

C#, chromedriver 2.41.
Would it be fixed? It's 877 days already behind :)
2019 still same issue, 1027 days now :)
Using hacky autoit scripts is all good but what if you run leaderless ??
Also the user:[email protected] trick dont work now days....
Firefox;

Still no way to enter Username and password....
Please it looks like, we all need this feature. Any expected delivery date or workaround ?
Most of companies requires a proxy authentication.
Feedback most appreciated. I keep trusting Selenium !
@cgoldberg any hints ?
Here's the version I use selenium-server-standalone 3.141.59 , jdk-11.0.2. firefox: 60.6.1esr, geckodriver-v0.24.0.
I have tried:
profile.SetPreference("network.proxy.http", "http://
\ : @ : ")
OR
String PROXY = "<proxy>:<port>" Proxy proxy = new Proxy() proxy.setProxyType(Proxy.ProxyType.MANUAL) proxy.setHttpProxy(PROXY) proxy.setSslProxy(PROXY) proxy.setSocksProxy(PROXY) proxy.setSocksVersion(5) proxy.setSocksUsername("<someDOmain>\<user>") proxy.setSocksPassword("<pwd>") options.setCapability(CapabilityType.PROXY, proxy)
Nothing works,
Thanks
As a workaround, you can install any proxy add-on for firefox and send the basic authorization as a header - Basic {username:password}
We made our own light weight add-on and using it in FF.
@adiohana thanks for your feedback. I'll check that workaround. So no straightforward way to do it... since I need to check for other webbrowser (IE, Chrome).
@viseth I'm sure there is a proper way to do it and fix the issue. I will try to dig deeper but it will take some time.
As for other browsers, in Chrome and FF you can use the same extension as long as you follow the API's. One more note, if you want to use an extension in Chrome Headless, this may not be possible (at least for Chrome v.63 so you will have to use a different workaround (Devtools API for example).
Let me know if you need more examples.
@adiohana definitly if you can me to some example, it will be great and save me time. Thanks a lot !
Code for extension is:
browser.webRequest.onBeforeSendHeaders.addListener(
handler,
{urls: ["<all_urls>"]},
['requestHeaders', 'blocking']
);
I'm using the localStorage to pass the username and password because I need it to be dynamic. If your's is always the same, you can state the value in the extension itself.
function handler(details) {
details.requestHeaders.push({name: "Proxy-Authorization", value: getAuthHeaderVal()});
return {requestHeaders: details.requestHeaders};
};
function getAuthHeaderVal() {
var res = localStorage.getItem('auth_header_value');
if (res) {
return res;
} else {
return "";
}
}
Then, when you launch your WebDriver, you can install the extension, get it's uuid and add values to localStorage like this:
driver.get("moz-extension://" + uuid);
driver.executeScript("localStorage.setItem('auth_header_value', 'Basic " + proxyHeaderValue + "')");
This is crazy that this is still broken :(
@shs96c should we close this in favour of https://github.com/SeleniumHQ/selenium/issues/6644 - As the main discussion about the complexities are being done there?
@adiohana, I've used that trick as far as I don't need headless, but now I need headless and it is not possible in that mode :(
@oleksiivasylenko
which browser you are using?
FF headless should work with extension.
Chrome headless will not work with extension and there is a workaround to use DevTools API to add headers for all requests. It will be available in Selenium 4 (https://github.com/SeleniumHQ/selenium/issues/6667). If you want, I can guide you how to do it manually until Selenium 4 will be released.
Thank you @adiohana!
I remember I used Chrome.
Please give me articles about workaround you mentioned.
Closed in favour of #6644, thanks for pointing it out @luke-hill
Code for extension is:
browser.webRequest.onBeforeSendHeaders.addListener( handler, {urls: ["<all_urls>"]}, ['requestHeaders', 'blocking'] );I'm using the localStorage to pass the username and password because I need it to be dynamic. If your's is always the same, you can state the value in the extension itself.
function handler(details) { details.requestHeaders.push({name: "Proxy-Authorization", value: getAuthHeaderVal()}); return {requestHeaders: details.requestHeaders}; }; function getAuthHeaderVal() { var res = localStorage.getItem('auth_header_value'); if (res) { return res; } else { return ""; } }Then, when you launch your WebDriver, you can install the extension, get it's uuid and add values to localStorage like this:
driver.get("moz-extension://" + uuid); driver.executeScript("localStorage.setItem('auth_header_value', 'Basic " + proxyHeaderValue + "')");
Hey there @adiohana , attempting to use this solution for my Selenium app. How are you grabbing the internal UUID after loading the extension?
i recently answered in SO
https://stackoverflow.com/q/56288424/3141682
i recently answered in SO
https://stackoverflow.com/q/56288424/3141682
@adiohana mind if I take a quick peek at your maifest.json?
@limsammy
`{
"name": "Name",
"version": "1.0.31",
"manifest_version": 2,
"description": "Description",
"background": {
"scripts": [ "background.js"]
},
"browser_action": {
"default_icon": "startup.png",
"default_title": "Title"
},
"icons": {
"48": "startup.png"
},
"permissions": [
"storage",
"webRequest",
"webRequestBlocking",
"
]
}`
Most helpful comment
2018, still facing proxy auth issues.

C#, chromedriver 2.41.
Would it be fixed? It's 877 days already behind :)