I have a web page that I am trying to authenticate against, and am
having some difficulty with preforming a retry if the initial login
fails for whatever reason.

The site/endsite code is a follows:


Code:
--------------------

Site "mysite" -subsequent
MatchForm #1 -name "frmLogin"
MatchField #1:1 -type "text" -name "userName"
DebugPrint "Matched Field 'userName'"
MatchField #1:2 -type "password" -name "password"
DebugPrint "Matched Field 'password'"
MatchField #1:3 -type "image" -name "Submit"
DebugPrint "Matched Field 'Submit'"
EndSite
DebugPrint "*** Successfully matched login form ***"
Call DoLogin
EndScript

--------------------


This correctly calls my 'DoLogin' code which is:


Code:
--------------------

Sub DoLogin
Set ?LoginOK 0
Repeat
SetPrompt "Username:"
FocusInput #1:1
TextInput #1:1 -value "$username"
DebugPrint "Performed entry action TextInput " $username " into control id#1:1"

SetPrompt "Password:"
FocusInput #1:2
TextInput #1:2 -value "$password"
DebugPrint "Performed entry action TextInput " $password " into control id#1:2"

SetPrompt "Please edit your login variables."

FocusInput #1:3
PressInput #1:3
DebugPrint "Submit action performed"

Call CheckLoginResult

If ?LoginOK EQ 1
Break
EndIf
EndRepeat
EndSub
--------------------


The 'CheckLoginResult' routine waits for 2 seconds, then checks for the
various messages on the screen. If you have logged in OK it sets the
?LoginOK flag, otherwise it either prompts user to enter new password,
or do something else, and then it finishes and control returns to the
'DoLogin' routine. If the login wasn't OK, then the repeat loop kicks in
and it (should) try to login again.

Because I am having to wait several seconds within my 'CheckLoginResult'
code, the SecureLogin script engine "misses" any '-subsequent' events so
this only triggers once hence the reason for the repeat/endrepeat loop
in there.

Now the logic is all OK and the repeat loop is looping, but for some
reason it is failing to re-enter any text into the two input boxes. It's
almost like the script has now "forgotten" which input box is which and
they need to be re-matched somehow ?

Anyone know how can I get the textinput commands to work on a
second/third attempt ?


--
clovercne
------------------------------------------------------------------------
clovercne's Profile: https://forums.netiq.com/member.php?userid=1699
View this thread: https://forums.netiq.com/showthread.php?t=47933