Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling "Authentication Required" alert box with Python 2.7 + Selenium Webdriver

I am having an issue with a secure URL:

Opening the URL creates an "Authentication Required" alert box with username and password fields.

I am fairly new to Selenium Webdriver and Python. I am not familiar with handling alerts and am currently manually typing in credentials until I can get this figured out. I have already tried adding my username/password into the URL. This does not work for me.

Could someone please point me in the direction of entering keys into username and password fields in an alertbox?

like image 963
Edwin Avatar asked Dec 05 '14 19:12

Edwin


1 Answers

In case of such authentication, you need pass username and password to server while accessing page to avoid authentication window(which is out of reach of selenium)

Suppose the url you're trying to access is: http://example.com

you'll have to access this url with credentials like following:

driver.get('http://username:[email protected]')

where username is your username and password is your password for the site.

like image 94
Alpha Avatar answered Oct 20 '22 17:10

Alpha