How to import an external datasheet and populate the data into Global Data sheet in QTP?

We will generate a script in QTP which imports and external data sheet and populate the data into the global datasheet and also exports the run time data sheet with the order number into an external location.


'Script to insert an order from external spreadsheet
'Populate the data into the globalsheet, define the datatable
'iterations using script and execute the insertorder

'Set the datatable iterations under test settings to
'Run one iteration only

'Step1: Import the data into the Runtime datatable

DataTable.Import("E:\Insert Order1.xls")

'Step 2: Get the rowcount and store it in a variable called rowcount

rowcount = DataTable.GetRowCount()

'Step 3: Set the datatable iterations, iterate from the first row till row count

For i = 1 to rowcount

'Step 4: Set the current row as the active row

DataTable.SetCurrentRow(i)

'Step 5: Insert order script with appropriate parameters

Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type DataTable.Value(1,1)
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable.Value(2,1)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable.Value(3,1)
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set DataTable.Value(4,1)
Window("Flight Reservation").WinButton("Insert Order").Click
Wait 8
OrderNo = Window("Flight Reservation").WinEdit("Order No:").GetRoProperty("text")
DataTable.Value(5,1) = OrderNo

Next

DataTable.Export("E:\InsertOrderResult.xls")

1 comments:

Anonymous said...

Very Well Explained. Thanks

Post a Comment

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