Write a Script in QTP 9.2 to perform different actions on Flight Reservation Application

Previous212223242526 27282930Next

We will generate a script in QTP 9.2 to invoke the Flight Reservation Application, Login into the application, Insert an order into the application and print the order number to the user, Open an Order, Update an Order, Fax an Order.


'Script to invoke the Flight Reservation Application
'Checking whether a login screen is opened

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

'Script to login in to the Application

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

'Script to insert an order and print the Order Number

Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "Test user"
Window("Flight Reservation").WinButton("Insert Order").Click
Wait 8
Ord_Num = Window("Flight Reservation").WinEdit("Order No:").GetRoProperty("text")
Msgbox "The Order Number is: "&Ord_Num

'Script to Open an Existing Order
'Here we will assume that the order is already inserted

Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Open Button").Click
Window("Flight Reservation").Dialog( "Open Order").WinCheckBox("Check order").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Order Number").Set Ord_Num
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

'Script to update an existing order

Window("Flight Reservation").Activate
Window("Flight Reservation").WinObject("Date of Flight:").Type "111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Los Angeles"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "Test User 1"
Window("Flight Reservation").WinButton("Update Order").Click

'Script to close the Application

Window("Flight Reservation").Close


Previous212223242526 27282930Next

7 comments:

Anonymous said...

Hi,

I am new to QTP, your blog is extremely good for new ones.
Have a question here for Invoking the App.
In this, do we have to make the Object Rep first learn the properties of Dialog window or what.
As on directly running this is giving error as Login object not found in OR.
Plz respond.

abdul said...

Nice Blog Thanks for efforts.

Anonymous said...

Yes you have to put the objects in the repository as usual.

Unknown said...

Please post how to write script for flight reservation.from begining step by step,,,Please

Unknown said...

I mean how to add objects in the object repositery,and run the qtp

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi,
Nice article can you explain about What are environment variables in vb script? How can they be used in QTP?
Thanks,
David,
QTP Developer

Post a Comment

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