1

software:python 2.7 + selenium browser:chrome 57

Hi,

I need to download some report files from a website. There is an os level pop-up window in which i have to input my username and password.

enter image description here

I have tried a solution which is to input my user name and my password with URL link. eg: https://username:[email protected]

but it does not work because my username includes "\" which would be translated to "/" in URL.

and i also tried to download a software named autoit, but i can not install it in my pc since security issue.

any solutions that i could try for my issue.

Thanks

1
  • 1
    Use Robo Class functions Commented Apr 14, 2017 at 13:08

1 Answer 1

2

The easiest way to authenticate in your case is to use username and password in URL. You still can authenticate with your username with "\" symbol, but you need to encode it first in URL format. For example, before forming final URL with credentials you can encode your username with urllib. This code should work in Python 2.7:

import urllib

username = "user\\name"
password = "password"
username_encoded = urllib.quote_plus(username)
URL = "http://%s:%[email protected]" % (username_encoded, password)
print(URL)

In the output you should see:

http://user%5Cname:[email protected]

And this URL will work fine with basic authentication (your case)

Sign up to request clarification or add additional context in comments.

3 Comments

hi, sunigos. i have tried this way on my end. it does work on my end. I think chrome would a reason for this. does it work on your end while you are using chrome?
I had a password with "@" symbol and used such encoding trick with chrome. And it worked for me
Thanks sunigos, i have chosen a different way to resolve my issue.Thank you so much for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.