UFT测试本地应用程序登陆小实例(描述性编程)

时间:2022-09-23 23:10:35
Dim username,password
Dim casecount,i
Dim currentid DataTable.ImportSheet "C:\Users\john\Desktop\william.xlsx",,"Action1"
casecount=datatable.Getsheet("Action1").GetRowCount For i = To casecount
username=DataTable("username","Action1")
password=DataTable("password","Action1")
Dialog("Login").WinEdit("Agent Name:").Set username
Dialog("Login").WinEdit("Password:").Set password
Dialog("Login").WinButton("OK").Click If Dialog("Login").Dialog("Flight Reservations").Exist() Then
ex=DataTable("ex","Action1")
ac=Dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").GetROProperty("text")
If ex=ac Then
DataTable("test","Action1")="PASS"
else
DataTable("test","Action1")="Fail"
DataTable("acresult","Action1")=ac
End If
if Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Exist() Then
Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
End if
elseif Dialog("Flight Reservations").WinButton("确定").Exist() Then
Dialog("Flight Reservations").WinButton("确定").Click
msgbox "test"
If window("Flight Reservation").Exist() Then
currentid=dataTable.GetSheet("Action1").GetCurrentRow
window("Flight Reservation").Close
If currentid=casecount Then
dataTable("test","Action1")="PASS"
else
reporter.ReportEvent micFail,"Flight","wrong user and password"
End If
else
reporter.ReportEvent micFail,"Flight","No response"
End If
End If
DataTable.GetSheet("Action1").SetNextRow
Next
DataTable.Export "C:\Users\john\Desktop\william.xlsx"
'Window("Flight Reservation").Close 'Dim casecount
'
'DataTable.ImportSheet "C:\Users\john\Desktop\william.xlsx",1,"Action1"
'casecount=datatable.Getsheet("Action1").GetRowCount
'msgbox "123 "&casecount&" dddd" 'Dialog("Login").WinButton("Cancel").Click