HTTP basic authentication URL with "@" in password

HttpSeleniumHttp AuthenticationSaucelabs

Http Problem Overview


I'm trying to set up some selenium tests to our staging server using Sauce Labs. It's behind a basic http auth, so theoretically I could set the selenium URL to http://user:[email protected]. However, the password contains a "@", causing all sorts of problems as you can imagine. I tried escaping it with a backslash but that did nothing from what I can tell.

So,

  1. is there an alternative way to do http authentication using selenium, i.e., not via the URL. Or,

  2. is there a way to use URL-based auth but somehow tell the browser that the "@" is part of the password?

Http Solutions


Solution 1 - Http

You just need to encode special characters like that before passing them as part of the URL, so @ would need to be passed as %40, eg:

https://user:password%40www.example.com

(I typically use this - http://meyerweb.com/eric/tools/dencoder/ - for my en/decoding needs.)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjraedeView Question on Stackoverflow
Solution 1 - HttpadmdrewView Answer on Stackoverflow