|
4#
楼主 |
发表于 2006-1-16 10:52:38
|
只看该作者
增加了几条日志信息
'$Include "sqautil.sbh"
Sub Main
Dim Result As Integer
Dim dp_id as Long
Dim dp_Result as Long
Dim strName as String
Dim strPassWord as String
'Initially Recorded: 2006-1-13 14:26:45
'Script Name: login
sqalogmessage sqanone,"启动应用程序",""
StartApplication """D:\Program Files\plt\OilportSetup\oilport.exe"""
dp_id = SQADatapoolOpen ("dp", FALSE, SQA_DP_SEQUENTIAL, FALSE)
dp_Result = SQADatapoolFetch (dp_id)
while dp_Result <> sqaDpEOF
dp_Result = SQADatapoolValue (dp_id, "name", strName)
dp_Result = SQADatapoolValue (dp_id, "password", strPassWord)
dp_Result = SQADatapoolFetch (dp_id)
EditBox Click, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_userName;\;Type=EditBox;Index=0", "Coords=23,2"
'输入用户名
InputKeys strName
EditBox Click, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_password;\;Type=EditBox;Index=0", "Coords=49,0"
'输入用户密码
InputKeys strPassWord
GenericObject Click, "Type=Form;Name=FrmLogin;\;Type=Control;Name=btn_login", "Coords=57,17"
Window SetContext, "Type=Form;Name=MainForm;VisualText=新港信息系统", ""
Window SetContext, "Type=Form;Name=MainForm", ""
'验证是否成功登录
Result = RegionVP (CompareImage, "", "VP=Region Image;Wait=2,30;Coords=205,392,574,561")
if result = 1 then
'如果成功登录,注销用户,清除用户名及密码,取datapool的下一条数据
GenericObject Click, "Type=Form;Name=MainForm;\;Type=Control;Index=8;\;Type=Control;Index=0", "Coords=24,11"
Window SetContext, "Class=WindowsForms.Window.808", "Activate=0"
GenericObject Click, "Class=WindowsForms.Window.8;ClassIndex=1", "Coords=46,28"
Window SetContext, "Type=Form;Name=FrmLogin", ""
EditBox Left_Drag, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_userName;\;Type=EditBox;Index=0", "Coords=45,9,-63,9"
InputKeys "{BKSP}"
EditBox Left_Drag, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_password;\;Type=EditBox;Index=0", "Coords=47,8,-10,8"
InputKeys "{BKSP}"
EditBox Click, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_userName;\;Type=EditBox;Index=0", "Coords=7,10"
sqalogmessage sqapass,"正确的用户名及密码","该用户成功登录"
else
'如果用户名、密码错误,无法登录,直接清除用户名及密码,取datapool的下一条数据
sqalogmessage sqapass,"错误的用户名及密码","该用户不能登录"
Window SetContext, "Type=Form;Name=FrmLogin", ""
EditBox Left_Drag, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_userName;\;Type=EditBox;Index=0", "Coords=100,9,-70,9"
InputKeys "{BKSP}"
EditBox Left_Drag, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_password;\;Type=EditBox;Index=0", "Coords=100,8,-70,8"
InputKeys "{BKSP}"
EditBox Click, "Type=Form;Name=FrmLogin;\;Type=Control;Name=txt_userName;\;Type=EditBox;Index=0", "Coords=7,10"
end if
wend
dp_Result = SQADatapoolClose (dp_id)
End Sub |
|