Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the Python bindings for Selenium2 with the Chrome webdriver. I need to access a site that is protected with basic HTTP authentication.

from selenium import webdriver

driver = webdriver.Chrome() 

I would expect this to work, but it seems that Chrome ignores the username and password given as part of the URL. Chrome will pop the authentication dialog and the script will hang until I manually type in the credentials. Chrome will forget this username and password, so I have to type it in every time I run the script.

share|improve this question
This kinds of question comes up a lot here. Have you tried searching the site for "selenium basic authentication" (…)? – user246 May 30 '12 at 14:25
It's been a long time since I posted this, but the above code now works with the latest selenium bindings and the latest Chrome webdriver. ( & – jrdmcgr Mar 19 '13 at 20:32

Does this help ? (ops, after the trouble, I realized your issue is with Chrome) but this is working fine on Firefox 9.0.1 on Windows 7

    String configFile = "/apps/configs/logins.cfg";

    // server, port, userid, password defaults
    String userid   = "";
    String password = "willeyCoy0tt3";
    String server     = "";
    String securePort = "447";

    // load the properties file - this might throw an exception
    //    if it cannot find or cannot open the file 
    Properties prop = new Properties();
    prop.load(new FileInputStream( configFile ));

    //get the values
    userid   = prop.getProperty( "user" );
    password = prop.getProperty( "password" );

    baseUrl = "https://" + userid + ":" + password + "@" + server + ":" + securePort + "/services/login.html";

    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(35, TimeUnit.SECONDS);

    // after that, just use to load the other pages, for example
    driver.get(baseUrl + "/services/listOrders.html");
share|improve this answer

If you are running on Windows you can create a little executable that fills the popup and presses OK using AutoHotkey, and run it after driver.get()

Maybe it's not the cleanest solution, but it works.

share|improve this answer
This does not cover well where we have re-directs, delayed redirects and links that all result in pages that need http authentication, and including SSL connections. Fun and games with getting the timing right using Autoit (similar solution as presented here - AutoHotkey). – user4515 Dec 11 '12 at 12:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.