Question

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?

Was it helpful?

Solution

@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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top