RSS Feed

QTP – Create a Simple Script without Recording

If the QTP’s recording engine is used to record a test scenario, then the script will have following issues:

Script will have hardcoded values
1. No proper naming convention
2. No modularity
3. No reusability
4. Maintenance is difficult
5. Difficult to accommodate frequent changes
6. Difficult to debug
How to overcome these problems?


Create your own script… do not use recorded script..

Let us create a simple hand coded script and then compare with the recorded one.

Recorded Script:

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(“Agent Name:”).Type micTab
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4eece6099d2b0bb2783b322b99abefc8f36ecf1c”
Window(“Flight Reservation”).WinMenu(“Menu”).Select “File;Exit”

Script created without Recording:

‘Script – “Login and Logout” the Flight application
‘Username and Password are parameterized through DataTable
‘ Purpose – Demonstrates creating script without Recording Engine
‘Author – Thomas Vinod
‘Copyrights – All rights reserved

Dim uname, pwd
SystemUtil.Run “C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe”
Dialog(“LoginDialog”).WinEdit(“PasswordEdit”).SetSecure Crypt.Encrypt(pwd)
Window(“FlightReservationWin”).WinMenu(“Menu”).Select “File;Exit”

Compare both the scripts:

Recorded script:

1. No proper naming convention
2. Test data is hardcoded

Script without recording:

1. Proper naming convention is used
2. Test data is parameterized
3. Easy maintenance

How to create a script without recording?

1. Create local repository / shared repository with proper logical name for each object (
2. Parameterize Test Data from data table (
3. Start typing the code… Dialog( –> press open bracket that shows the number objects available, then just select the required object
4. Use appropriate actions such as Click, Set, Type, etc

Run both the scripts and view the results. It is even easy to analyze the results if proper naming convention is used in the object repository. If there is any need to execute the same test scenario for multiple iterations, we need to add just some more rows in the data table, but there is no need to copy and paste the same recorded script again and again.

I hope this gives a fair idea of how to create a simple hand coded script in QuickTest Professional (QTP).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: