10-27-2010, 01:56 PM
Hi Cocojava,
if I am getting it clearly, you want to login once and do the flight operation multiple times. let me know if I am incorrect.
for this you will need to create two reusable, one for login and one for flight operation, put the login code into the login reusable, you can pass the username and password either using data table or action parameter, then the flight operation part could be in another reusable and pass you data in the datatable, could be on multiple rows depending on your requirement. then you just need to iterate through all the rows of your this reusable only. coz if you iterate for a single reusable consisting both login and operation together, everytime QTP will login and do the same operations and corresponding login data will be required. same goes if you put data in your global sheet.
your login reusable could be something like
flightoperation
with the data in datatable something like
your test will be look like somewhat as below
note that nothing to put in global datasheet in this case
hope this will help you, let me know if you any difficulties.
if I am getting it clearly, you want to login once and do the flight operation multiple times. let me know if I am incorrect.
for this you will need to create two reusable, one for login and one for flight operation, put the login code into the login reusable, you can pass the username and password either using data table or action parameter, then the flight operation part could be in another reusable and pass you data in the datatable, could be on multiple rows depending on your requirement. then you just need to iterate through all the rows of your this reusable only. coz if you iterate for a single reusable consisting both login and operation together, everytime QTP will login and do the same operations and corresponding login data will be required. same goes if you put data in your global sheet.
your login reusable could be something like
Code:
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set Parameter("user")
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").Set Parameter("pwd")
Dialog("Login").WinEdit("Password:").Type micReturn
flightoperation
Code:
f Window("Flight Reservation").Exist Then
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type DataTable("FlightDate", dtLocalSheet)
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("From", dtLocalSheet)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("To", dtLocalSheet)
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select 1
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set DataTable("Name", dtLocalSheet)
Window("Flight Reservation").WinButton("Insert Order").Click
End If
Code:
date from to name
102810 London Los Angeles x
102910 Denver London y
103010 Paris Portland z
Code:
RunAction "Login [Login]", oneIteration, "name", "mercury"
RunAction "FlighOPeration [FlightOperation]", allIterations
hope this will help you, let me know if you any difficulties.