1

I tried login to firefox authentication window by following code :

WinWaitActive("Authentication Required","","120")
If WinExists("Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf

But the same dint worked for chrome even though it has the same title as firefox.

Any idea?

Vish Shady
  • 327
  • 1
  • 5
  • 15
  • Whats the link you are trying to open? – Milos Dec 13 '13 at 23:12
  • If we open a google , authentiation window pops up for our proxy credentials. Same way for our internal applications we need to login through the windows pop up. for example say http://qcm-test.qualcomm.com – Vish Shady Dec 14 '13 at 06:04
  • Did you check the complete title string with the Window Information Tool to exactly match your expected title? – Samoth Dec 14 '13 at 09:49
  • @Samoth, Yes i did check. For Chrome browser when i checked the title of the authentication pop up, it is showing "new tab" or "about:blank" depend on the new tab is launched or a window. where this is not a case for firefox or internet explorer browsers. – Vish Shady Dec 14 '13 at 10:15
  • So is it anything we can take the class details? – Vish Shady Dec 14 '13 at 10:15
  • 2
    Before asking here, you need to debug your code entirely. Is it failing to detect the window or is the command Send failing? I also recommend fiddling with Opt("WinSearchChildren", 1) ;0=no, 1=search children also Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase – Milos Dec 14 '13 at 16:04
  • [Related](https://stackoverflow.com/q/19357634/4157124). – user4157124 Oct 26 '17 at 20:51

3 Answers3

2

@Milos @Samoth thanks for spending to solve my query.

Using Autoit windows info tool, i could not identify the windows tile in chrome thats not a case in FF or IE. Instead of that "Autentication Required" identified as visible text.

So modifying the code to

WinWaitActive("","Authentication Required","120")
If WinExists("","Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf

did the trick for Chrome browser.

Vish Shady
  • 327
  • 1
  • 5
  • 15
0

If somebody is interested in Selenium for Chrome using Visual Studio and NUnit Framework, you can follow these steps:

  1. Install AutoItX.Dotnet NuGet package for your testing project

  2. Write the following code:

        IWebDriver _driver = new ChromeDriver();
        _driver.Navigate().GoToUrl(@"your_url");
    
        AutoItX.WinActivate("", "Authentication required");
        AutoItX.Send(@"domain_user_name{TAB}password{ENTER}");
    

and you are logged in your web application.

Cristi G
  • 11
  • 1
0

A lot of credit for this goes to @CristiG for this.

  1. You will need the AutoItX.Dotnet NuGet package
  2. 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.

Cameron
  • 2,903
  • 1
  • 30
  • 31