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:
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
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?
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…
@Ven Perhaps I made this implementation Win8 specific. Let me know what OS you’re running on and I’ll see about posting an update.
windows 7
And could you do one for chrome please!
I’m sorry that I’m asking for a lot, but I very new to this
I wish I could. Like I said at the end of the post, Chrome and Firefox implement the security stuff differently. They don’t just use the stock OS authentication mechanism and render their own window that’s accessible with UIAutomation. I’ve read of folks using AutoIT scripts and reg/config hacks to get around this in Chrome and Firefox. If you do come across a solution, let me know!
Check out my latest post which addresses this. http://repne.wordpress.com/2013/02/25/using-uispy-to-handle-the-windows-security-dialog-in-windows-7/
And thanks again for asking this!
Pingback: Using UISpy to Handle the Windows Security Dialog in Windows 7 | Nithin's Blog
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!