QTP – Record a simple script

by seetaram on October 1, 2011

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:

  1. Open Flight application
  2. Enter appropriate username
  3. Enter appropriate password
  4. Click on OK button
  5. User should get logged in
  6. Click on File menu –> Click on Exit option
  7. Flight application should get closed

Record the above Test Steps as mentioned below:

  1. Open QTP
  2. Click on Record (or Automation –> Record or press F3)
  3. Click on Start –> Program Files –> QuickTest Professional –> Sample Applications –> Flight
  4. Flight Login window gets displayed on the desktop
  5. Type “admin” as username
  6. Type “mercury” as password
  7. Click on “OK” button
  8. User should get logged into the Flight application
  9. Click on File –> Exit to close the application
  10. Click on “Stop” (or Automation –> Stop or press F4)
  11. 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"
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.

Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email