Windows Authentication at web site launch


Hi all:
I am attempting to automate an intranet site. Basically, when I launch the url, I receive a login screen on each browser I have tried. I have saved the creds to login and even with that, I still have to hit the OK button to login. The problem is-- this isn’t a form that can be controlled by Selenium (or if it is, I haven’t found out how). Since I have been unable to control login, I am unable to automate anything without a prior manual login to the web page.

I was wondering-- has anyone had to automate a web site that uses windows auth? If so, how have you fixed the issue?



Hi @micheleaz
What you could try is to provide your username and password for the website in your .get() method (when you are opening the page)

For example:
driver.get('https://username:[email protected]/')

Another way is to use third-party tools like Autoit and integrate the script to your framework like described in this post.
Happy testing!


Hey @micheleaz

the typical approach in Selenium to handle these cases is what @smatijas proposed with sending the credentials as part of the navigation url. The typical PageObject in Ranorex Webtestit gets scaffolded with a premade open(url) method, where you’d just pass the target url prefixed with username:password.

For other cases where you need to handle native dialogs you may come pretty far using Seleniums Alert API.

I haven’t tested this myself but I guess something along the following lines might also work

// switch to the native alert
  .sendKeys("YourUsername"); // send username as the first textbox will be auto-selected
  .sendKeys(Keys.TAB);  // send the tab key to switch to the password field ( most likely an import is needed for Keys)
  .sendKeys(Keys.ENTER); // Send enter to confirm
  // .accept()
  // accept might works as well instead of sending ENTER.
  //This should also automatically switch back to the window context


Thanks very much! I will give these ideas a try!