1

I have written several Selenium Website Tests, however, this is my first with a site that is set to Windows Authentication.

I have been trying with Chrome and IE.

With IE I can successfully login to the site, and I see AutoIt typing and I can see that the browser successfully loads the correct page after login, however, the driver never has a connection to that browser.

With Chrome, I can never find the window to connect with AutoIt.

Using C#. See inline code comments for more specifics on the errors.

        try
        {
            var autoIT = new AutoItX3();
            if (IE) //IE Driver - Driver looses connection with the window immediately on Navigate, but AutoIT login works.
            //(Driver does work fine if I go to a non-windows authentication site)
            {
                driver.Navigate().GoToUrl(testConfig.Url);
                System.Threading.Thread.Sleep(2000);
                //driver.CurrentWindowHandle crashes, 'No Window Exits'
                var driverHandles = driver.WindowHandles; //result is 0
                var test4 = autoIT.WinActive("Windows Security");
                autoIT.WinActivate("Windows Security");
                autoIT.Send("zzzzzzz");//Don't need user as it remembers
                System.Threading.Thread.Sleep(1000);
                autoIT.Send("{TAB}");
                autoIT.Send("{ENTER}");
                //Visually I can see Browser is logged in and full page loads.
                autoIT.WinActivate("EDB Data Manager - Internet Explorer");
                var test5 = autoIT.WinGetTitle("EDB Data Manager - Internet Explorer");
                System.Threading.Thread.Sleep(2000);
                driver.Url = testConfig.Url;
                System.Threading.Thread.Sleep(2000);
                var driverHandles2 = driver.WindowHandles; //result is still 0

                //this will fail
                IWebElement userName = driver.FindElement(By.Id("WellsCard"));

                //I've tried refreshing or navigating to the url again with no success.

            }
            else //chrome Driver Driver maintains connection with the window immediately, but AutoIT fails, as I can't find window.
            {

                driver.Navigate().GoToUrl(testConfig.Url);
                System.Threading.Thread.Sleep(2000);
                var test7 = autoIT.WinExists("Authentication Required");
                var tes8 = autoIT.WinExists("data:, - Google Chrome");
                var test9 = autoIT.WinExists("EDB Data Manager - Internet Explorer");
                var test10 = autoIT.WinExists("Untitled - Google Chrome");
                //None exist, so this will not work.
                autoIT.WinActivate("Authentication Required");
                autoIT.Send("myUserName");
                autoIT.Send("{TAB}");
                autoIT.Send("zzzzz");
                System.Threading.Thread.Sleep(1000);
                autoIT.Send("{TAB}");
                autoIT.Send("{ENTER}");
            }

        }
        catch (Exception ex)
        {
            output.OutputMessage(ex.ToString());
        }
user4157124
  • 2,809
  • 13
  • 27
  • 42
caseynshan
  • 21
  • 3
  • Some Links that I used when getting this far..http://stackoverflow.com/questions/11837442/http-authorization-with-webdriver-and-popup-window http://stackoverflow.com/questions/14621212/autoit-code-for-handling-windows-authentication-pop-up-using-selenium-webdriver http://stackoverflow.com/questions/19357634/selenium-autoit-script-to-handle-windows-authentication-pop-up-on-chrome – caseynshan Sep 19 '16 at 15:57

0 Answers0