Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
800 views
in Technique[技术] by (71.8m points)

selenium - HTTP basic authentication URL with "@" in password

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...