A lot of credit for this goes to @CristiG for this.
- You will need the AutoItX.Dotnet NuGet package
- Use this code to login, just ignore the commented out lines unless you want to see if you can get it to work without the Sleep() for robustness.
new Thread(() =>
{
Thread.Sleep(500);
// AutoItX.WinWait("", "Authentication required");//fails
AutoItX.WinActivate("", "Authentication required");
// AutoItX.WinWaitActive("", "Authentication required");//fails
AutoItX.Send(@"username{TAB}pass{ENTER}");
}).Start();
driver.Url = "http://yourpage.com";
Cristi's method didn't work for me, because the call to GoToUrl() blocks when the login dialog box pops up.
But that can be fixed simply by starting a thread to do the login before calling GoToUrl().
It would seem you could use either WinWait() or WinWaitActive() to eliminate the need for the Thread.Sleep(), but I couldn't get either to work, so I was left with the ugly Thread.Sleep(), but this approach
works for me.