标题: 关于登录验证的脚本 [打印本页] 作者: zhenqi 时间: 2007-5-16 16:14 标题: 关于登录验证的脚本 请哪位高手帮我看一下这段代码,哪里写的有问题,在运行的日志里显示“Unexpected Active Window”的警告,我逐行调试,是“ window setcontext, "caption=提示","" ”出的问题,请问该怎样修改呢?
'$include "sqautil.sbh"
Sub Main
Dim Result As Integer
dim x as integer
dim strid as string
dim strpsw as string
dim dp as long
StartApplication "xx.exe"
dp=SQADatapoolOpen("登录")
for x=1 to 4
Call SQADatapoolFetch(dp)
Call SQADatapoolValue(dp,1,strid)
Call SQADatapoolValue(dp,2,strpsw)
Window SetContext, "Type=Form;Name=LoginFrm", ""
EditBox DblClick, "Type=EditBox;Name=txt_userid;State=Hidden", "Coords=54,9"
InputKeys strid
EditBox DblClick, "Type=EditBox;Name=txt_psw;State=Hidden", "Coords=55,7"
InputKeys strpsw &"{ENTER}"
window setcontext, "caption=提示",""
Result = WindowVP (Exists, "caption=提示", "VP=Window Existence;wait=2,3;expectedresult=fail")
if result=0 then
inputkeys "{enter}"
end if
if result=1 then
Window SetContext, "Type=Form;Name=MDIMain", ""
end if
next
call sqadatapoolclose(dp)
Window CloseWin, "", ""
Do
Window SetContext, "CurrentWindow",""
Result = SQAGetPropertyAsString("CurrentWindow","Caption",tempCaption)
If Result = SQASuccess Then
If InStr(tempCaption,"提示") = 0 Then
' Window WMinimize,"",""
Window CloseWin,"",""
InputKeys "%{Tab}"
x=x+1
Else
Exit Do
End If
Else
SQAConsoleWrite "Window caption not found"
InputKeys "%{Tab}"
x=x+1
End If
Loop While x=5