Automating the “Windows Security” Dialog with UIAutomation

I decided to finally learn some Selenium in order to test an internal Line of Business (LOB) web application. After a quick crash course on Selenium automation, I got a prototype for my test initialization working, but quickly hit this:

image

I was a bit miffed to learn that Selenium does not natively handle the authentication dialog. Bummer. After fighting with UIAutomation for several hours, here’s a solution I came up with. Hopefully this will save some other people time.

Note that this code only works with IE. WebKit browsers implement the authentication dialog in their own funky ways. But for my purposes, our LOB app is IE based only. #winning

Advertisements
This entry was posted in testing, Work and tagged , , , , , . Bookmark the permalink.

9 Responses to Automating the “Windows Security” Dialog with UIAutomation

  1. Ven says:

    Hey, This is exactly what I’ve been looking for, but when I seem to run it on IE, the code breaks when it reaches
    AutomationElement userList = windowsSecurityDialog.FindFirst(TreeScope.Children, userListCondition);
    and gives me a null value, I’m not entirely sure why, but I was also wondering where did you obtain these parameters from?

    • Ven says:

      Sorry, it retrieves a null value and breaks on AutomationElement userTile = userList.FindFirst(TreeScope.Children, userTileCondition); where userList == null

      And I’m not sure if the same conditions apply for my case because I am trying to access a server website…

  2. Pingback: Using UISpy to Handle the Windows Security Dialog in Windows 7 | Nithin's Blog

  3. Ven says:

    Great tutorial, but I eventually changed the configuration settings on my server that I’m accessing and completely removed the windows authentication and simply used IP filtering/restriction for the server in IIS manager. In my case, the security dialog box was not necessary since it was only being used for testing purposes, but once again, thank you for looking into this!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s