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?
@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.
If somebody is interested in Selenium for Chrome using Visual Studio and NUnit Framework, you can follow these steps:
Install AutoItX.Dotnet NuGet package for your testing project
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.
- 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.