I am trying to automate my test cases using selenium webdriver in java. It involves Basic Authentication Dialogs. For making IE, Chrome, FF Compatible using kind of same approach I have to use AutoIT I am done with IE and FF but for Chrome it is not working. I am using AutoIT Window Info
tool for finding out Class and Control Name. But Chrome is pretty different in that case can anyone help?
Here is code for working IE and FF
$classForBasicAuthenticationWindow = "[CLASS:#32770]"
$username = "XXXXXX"
$password = "XXXXXX"
WinWait($classForBasicAuthenticationWindow,"",120)
If WinExists($classForBasicAuthenticationWindow) Then
WinActivate($classForBasicAuthenticationWindow)
Send($username)
Send("{TAB}")
Send($password & "{Enter}")
EndIf
It is similar for FF, The above is for IE
For Chrome I have written this so far if you consider the window info
tool you will understand that the popup is not a different window in case of chrome. So it become a bit complicated. Anyways here is what I have tried :
$classForBasicAuthenticationWindow = "[CLASS:Chrome_WidgetWin_1]"
$username = "XXXXX"
$password = "XXXXX"
WinWait($classForBasicAuthenticationWindow,"",120)
If WinExists($classForBasicAuthenticationWindow) Then
WinActivate($classForBasicAuthenticationWindow)
While 1
$isAuthenticationRequiredVisible = ControlGetHandle($classForBasicAuthenticationWindow, "", "[CLASS:ViewsTextfieldEdit; INSTANCE:2]")
If $isAuthenticationRequiredVisible <> "" Then
MsgBox($isAuthenticationRequiredVisible)
ExitLoop
EndIf
WEnd
ControlSend($classForBasicAuthenticationWindow, "", "[CLASS:ViewsTextfieldEdit; INSTANCE:2]", $username)
EndIf
Why are you not opening your URL as so (by passing the login credentials in the URL)
@driver.get "#{username}:#{password}@#{URL}"
an example
@driver.get "user:pass@my.domain.com"