QuickTest Professional provides a Record and Playback engine, which can be used to record a script and playback the same to reproduce the test actions. Let us record a simple script, steps are as given below:
- Open Flight application
- Enter appropriate username
- Enter appropriate password
- Click on OK button
- User should get logged in
- Click on File menu –> Click on Exit option
- Flight application should get closed
Record the above Test Steps as mentioned below:
- Open QTP
- Click on Record (or Automation –> Record or press F3)
- Click on Start –> Program Files –> QuickTest Professional –> Sample Applications –> Flight
- Flight Login window gets displayed on the desktop
- Type “admin” as username
- Type “mercury” as password
- Click on “OK” button
- User should get logged into the Flight application
- Click on File –> Exit to close the application
- Click on “Stop” (or Automation –> Stop or press F4)
- Click on File –>Save / Save As –> give the file name (FlightLogin) and click Save
Following screenshots show the record / stop options on the QTP window.
Below is the VBScript which the QTP has recorded through the Recording engine.
'------------------------------------------------------------------------------------------------------------------------------------------------------- 'This script records the steps to login to the Flight sample application and the closes the application 'Author - Seetaram Hegde 'Copyrights - All rights reserved '------------------------------------------------------------------------------------------------------------------------------------------------------- SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").WinEdit("Agent Name:").Set "admin" Dialog("Login").WinEdit("Password:").SetSecure "4e8758ec4edf2b5363442d3ea046aaead8404f14" Dialog("Login").WinButton("OK").Click Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
This post explains the basic recording using QTP. I think whoever wants to learn QTP should start from this point so that the understanding will be easier.