Handling Browser Authentication using Selenium

EDIT in 2015:

This answer is outdated. WebDriver nowadays supports authentication! See How to handle authentication popup with Selenium WebDriver using Java


Original answer:

This is not handled very well by Selenium.


You can try using http://username:[email protected]/yourpage

instead of just http://example.com/yourpage

However, as far as I know, Firefox will still pop up a browser dialog requesting a confirmation.


You can try Robot if you’re using Java (or any similar tool like AutoIt).


You could use driver.manage().addCookie() if you’re using WebDriver.


Or a custom FirefoxProfile that has already passed the authentication once.

Leave a Comment