Write a script using Functions to invoke the Flight Reservation Application and pass the Login values from external Excel Sheet

LoginFR username, password

Public Function LoginFR(byval username, byval password)

'Create an Object Variable to interact with Excel Library

Set xlapp = CreateObject("Excel.Application")

'Open the exisiting workbook

Set wbook = xlapp.workbooks.Open("E:\LoginFlightR.xls")

'Create a pointer to the first sheet in the workbook

Set wsheet = xlapp.worksheets(1)

'Get the row count

rowcount = wsheet.usedrange.rows.count

For i = 1 to rowcount-1
If not Dialog("Login").Exist(0) Then
InvokeApplication "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
End If

username = wsheet.cells(i+1,1).Value
password = wsheet.cells(i+1,2).Value
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set username
Dialog("Login").WinEdit("Password:").Set password
Dialog("Login").WinButton("OK").Click
Wait 10
If Window("Flight Reservation").Exist(10) Then
wsheet.cells(i+1,3).Value = "Pass"
wsheet.cells(i+1,3).Font.Colorindex = 10
Else
wsheet.cells(i+1,3).Value = "Fail"
wsheet.cells(i+1,3).font.colorindex = 3
End If

Window("Flight Reservation").Close

Next
wbook.save
wbook.close
xlapp.quit

Set wsheet = nothing
Set wbook = nothing
Set xlapp = nothing

End Function

0 comments:

Post a Comment

/* Tynt Insight tracker ----------------------------------------------- */