Write a script in QTP 9.2 using Local data sheet

Write a script in QTP 9.2 using Local data sheet to invoke the application, login, Insert order using Local data sheet and closing the application.


Look at the four actions in our test we create in QTP

Action 1 – Invoke Flight Reservation Application.
Action 2 – Login to the Application.
Action 3 – Insert Order.
Action 4 – Close the Flight reservation Application.

Action 1 renamed as Invoke Application

If Not Dialog("Login").Exist(0) Then
App_Path = "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
InvokeApplication App_Path
End If

Action 2 renamed as Login

Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "Testuser"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click


Action 3 renamed as Insert Order

Here we use the local data sheet with values to be inserted. We will have DateofFlight, FlyFrom, FlyTo, OrderNo (which we will fetch to the datatable from application using GetROProperty, Result based on the orderNo generated we will print pass or fail.

Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type DataTable("DateofFlight", dtLocalSheet)
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("FlyFrom", dtLocalSheet)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("FlyTo", dtLocalSheet)
Window("Flight Reservation").WinButton("FLIGHT").Click
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
Wait 8
Orderno = Window("Flight Reservation").WinEdit("Order No:").GetRoProperty("text")
DataTable("Orderno",dtLocalSheet) = Orderno

If Orderno = " " Then
DataTable("Result",dtLocalSheet) = "Fail"
Else
DataTable("Result",dtLocalSheet) = "Pass"

End If

Action 4 renamed as Close

Window("Flight Reservation").Close

0 comments:

Post a Comment

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