William126

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

Dim username,password
Dim casecount,i
Dim currentid

DataTable.ImportSheet "C:\Users\john\Desktop\william.xlsx",1,"Action1"
casecount=datatable.Getsheet("Action1").GetRowCount

For i = 1 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(3) 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(5) Then
            Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
        End if
    elseif Dialog("Flight Reservations").WinButton("确定").Exist(10) Then
        Dialog("Flight Reservations").WinButton("确定").Click
        msgbox "test"    
        If window("Flight Reservation").Exist(3) 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

 

posted on 2018-03-18 15:47  William126  阅读(1171)  评论(0编辑  收藏  举报

导航