HP QuickTest Professional
is a solution for functional test and regression test automation. This
next-generation automated testing solution deploys the concept of
keyword-driven testing to enhance test creation and maintenance. Keyword-driven
testing is a technique that separates much of the programming work from the
actual test steps so that the test steps can be developed earlier and can often
be maintained with only minor updates, even when there are significant changes
in your application or your testing needs.
Using the keyword-driven
approach, test automation experts have full access to the underlying test and
object properties, via an integrated scripting and debugging environment that
is round-trip synchronized with the Keyword View.
QuickTest Professional
meets the needs of both technical and non-technical users. It works
hand-in-hand with HP Business Process Testing to bring non-technical
subject matter experts into the quality process in a meaningful way. Plus, it
empowers the entire testing team to create sophisticated test suites.
· Seat License: It is a machine locked
license. This license can be used only for a machine it was generated.
· Floating License: It can be used on any
machine which has network access to the floating license server. At any point
in time the machines using the QTP license cannot exceed maximum license count
on the server.
The Keyword View enables
you to create and view the steps of your test in a keyword-driven, modular,
table format. The Keyword View is comprised of a table-like view, in which each
step is a separate row in the table, and each column represents different parts
of the steps. You can modify the columns displayed to suit your requirements.
You create and modify tests by
selecting items and operations in the Keyword View and entering information as
required. Each step is automatically documented as you complete it, enabling
you to view a description of your test steps in understandable English.
Each operation performed on your
application during a recording session is recorded as a row in the Keyword
View.
For each row in the Keyword View, HP QuickTest displays a corresponding
line of script in the Expert View.
Advanced testers can view and
edit their tests in the Expert View, which reveals the underlying
industry-standard VBScript that QuickTest automatically generates. Any changes
made in the Expert View are automatically synchronized with the Keyword View.
The Expert View is composed of statements coded in the Microsoft
VBScript programming language. The Expert View provides an alternative to the
Keyword View for testers who are familiar with VBScript. You can also create
function libraries in HP QuickTest using VBScript.
· Key word driven testing
· Suitable for both client
server and web based application
· VBScript as the scripting
language
· Record and playback
Feature which helps in faster test script creation
· Easier maintenance and
powerful Data Driven capability. provides inbuilt methods to integrate with 3rd
party application like Excel, MS Access etc
· Operates stand-alone, or
could be integrated into HP Quality Center
· Identifies objects with
Unique Smart Object Recognition, even if they change from build to build,
enabling reliable unattended script execution
· Enables thorough
validation of applications through a full complement of checkpoints
· The screen shots can be
recorded of Run time error
QTP supports the following environments
·
Active X
·
Delphi
·
Java
·
.Net
·
Oracle
·
People Soft
·
Power Builder
·
SAP
·
Siebel
·
Stingray
·
Terminal Emulator
·
Visual Basic
·
Visual Age
·
Web
·
Web Services
QuickTest testing process
consists of 7 main phases:
1.
Create your test plan -
This is preparatory phase where you identify the exact test steps, test data
and expected results for you automated test. You also identify the environment
and system configurations required to create and run QTP Tests.
2.
Recording a session on your application - During this phase, you will execute test steps one by one on your
AUT, and QTP will automatically record corresponding VB script statements for
each step performed.
3.
Enhancing your test - In
this stage you will insert checkpoints, output values, parameterization,
programming logic like if…else loops to enhance the logic of your test script.
4.
Replay & Debug -
After enhancements you will replay the script to check whether it’s working
properly and debug if necessary.
5.
Run your Tests - In this phase you will
perform the actual execution of your Test Script.
6.
Analyzing the test results -
Once test run is complete, you will analyze the results in the Test Fusion
report generated.
7.
Reporting defects - Any
incidents identified needs to be reported. If you are using Quality Center,
defects can be automatically raised for failed tests in QTP.
HP QTP 11.0 contains the
following key elements:
·
Title bar, displaying the name of
the currently open test
·
Menu bar, displaying menus of
QuickTest commands
·
File toolbar, containing buttons to
assist you in managing tests
·
Test toolbar, containing buttons used
while creating and maintaining tests
·
Debug toolbar, containing buttons used
while debugging tests.
Note: The
Debug toolbar is not displayed when you open QuickTest for the first time. You
can display the Debug toolbar by choosing View
> Toolbars > Debug.
·
Action toolbar, containing buttons and
a list of actions, enabling you to view the details of an individual action or
the entire test flow.
Note: The
Action toolbar is not displayed when you open QuickTest for the first time. You
can display the Action toolbar by choosing View
> Toolbars > Action. If you insert a reusable or external action in a
test, the Action toolbar is displayed automatically.
·
Test pane, containing two tabs to
view your test-the Tree View and the Expert View Test Details pane, containing
the Active Screen.
·
Data Table, containing two tabs,
Global and Action, to assist you in Parameterzing your test Debug Viewer pane,
containing three tabs to assist you in debugging your test-Watch Expressions,
Variables, and Command. (The Debug Viewer pane can be opened only when a test
run pauses at a breakpoint.)
·
Status bar, displaying the status
of the test.
Object Repository is a centralized place for storing Properties of objects available in
AUT (Application Under Test). It is a test structure location where QuickTest
stores object information/properties captured during recording. It acts as
interface between test script and application in order to indentify the objects
during script execution. The Object Repository can be used to:
·
Add a new object in the
repository.
·
Rename logical name for
readability.
·
Configure the object
properties used to identify an object.
The Objects stored in the Object repository (OR) are called as Test
Objects. Actually it is just equivalent to the corresponding actual object
in AUT.
Object: It is a graphic user element in an application. It contains
structure and properties. In QTP windows, WebPages, button, edit boxes, check
boxes etc are termed as software object
1.
Shared Object Repository
(also called Global)
2.
Per-Action Object
Repository, (also called Local)
HP QTP identifies any GUI
Object based on its corresponding properties.
While recording, QTP identifies and store peculiar properties (as
defined in the Object Identification settings) in the object repository of the
GUI object. At run-time, QTP will compare the stored property values with the
on-screen properties, to uniquely identify the GUI object.
QTP supports 3 types of recording modes
·
Normal mode also called Contextual
- It is the default recording mode and takes full advantage of QTP's Test
Object Model. It recognizes objects regardless of their position on -screen.
This is the preferred mode of recoding and is used for most of the automation
activities.
·
Low-level recording mode -
This mode records the exact x, y co-ordinates of your mouse operations. It is
helpful in testing hash maps. It is useful for recording objects not identified
by normal mode of QTP. Records any object irrespective of environment or object
is supported by QTP. Recognizes all run time objects as windows objects. It is
used when an object is not identified by Quick test.
Use low-level recording for when you need to
record the exact location of the operation on your application screen. While
recording in normal mode, Quick Test performs the step on an object even if it
has moved to a new location on the screen. If the location of the object is
important to your test,
Low-level recording supports the following methods for each test
object:
WinObject test objects: Click,
DblClick, Drag, Drop, Type
Window test objects: Click,
DblClick, Drag, Drop, Type, Activate, Minimize, Restore, Maximize
Each step recorded in Low Level Recording mode is shown in the Keyword
View and Expert View.
·
Analog mode - This mode records exact
mouse and keyboard "movements" you perform in relation to the screen
/ application window. This mode is useful for the operation such as drawing a
picture, recording signature, drag and drop operations. The steps recorded
using analog recording is saved in a separate data file & file is stored
with the action in which the analog steps are recorded. HP Quick Test adds to
your test a RunAnalog statement that
calls the recorded analog file. You cannot edit Analog Recording steps from within
Quick Test.
q Record Relative to Screen: if the
operations you perform are on objects located within more than one window. This
mode is useful. In this mode Desktop screen is taken as base.
Syntax: Desktop.RunAnalog
"Track1"
q Record Relative to Window: if the
operations you perform are on objects located within one window, Quick Test accurately identifies the
window location on which the analog steps were performed even if the window is
in a different location when you run the analog steps. Quick Test does not
record any click or mouse movement performed outside the specified window.
Syntax: Window ("Login").RunAnalog "Track4"
HP QTP allows calling an action in 2 ways
1. Call to copy of Action - The
original action is copied in its entirety, including checkpoints,
parameterization, the corresponding action tab in the Data Table, any defined
action parameters, local object repository. The action is inserted into the
test as an independent, non-reusable action (even if the original action was
reusable). After the action is copied into your test, you can add to, delete
from, or modify the action just as you would with any other non-reusable
action. Any changes you make to this action after you insert it affect only
this action, and changes you make to the original action do not affect the
copied action. To view, Right-click & select Action > Insert Call to Copy.
2. Call to Existing an Action - In
this approach, a link is created to called Action. User can view the steps of
the action in the action view, but you cannot modify them. The called action’s
local object repository (if it has one) is also read-only. If the called
external action has data in the Data Table, however, you can choose whether you
want the data from the action’s data sheet to be imported as a local, editable
copy, or whether you want to use the (read- only) data from the original
action. (Columns and data from the called action’s global data sheet are always
imported into the calling test as a local, editable copy.) To modify a called,
external action, you must open the test with which the action is stored and
make your modifications there. The modifications apply to all tests that call
that action. If you chose to use the original action’s data when you call an
external action, then changes to the original action’s data are applied as
well. To view, Right-click & select Action
> Insert Call to Existing Action.
Application Under Test
(AUT) may contain objects that behave like standard objects but are not
recognized by QTP. You can define these objects as virtual objects and map them
to standard classes, such as a button or a check box. QTP emulates the user's
action on the virtual object during the run session. In the test results, the
virtual object is displayed as though it is a standard class object.
For example, suppose you want to record a test on a Web page
containing a bitmap that the user clicks. The bitmap contains several different
hyperlink areas, and each area opens a different destination page. When you
record a test, the Web site matches the coordinates of the click on the bitmap
and opens the destination page.
To enable QTP to click at the required coordinates during a run
session, you can define a virtual object for an area of the bitmap, which
includes those coordinates, and map it to the button class. When you run a
test, QTP clicks the bitmap in the area defined as a virtual object so that the
Web site opens the correct destination page.
You can define a virtual object using the Virtual Object Wizard Tools > Virtual Objects > New Virtual
Object. The wizard prompts you to select the standard object class to which
you want to map the virtual object. You then mark the boundaries of the virtual
object using a crosshairs pointer. Next, you select a test object as the parent
of the virtual object. Finally, you specify a name and a collection for the
virtual object.
We can read operation system details using the Built in Environment
Variable. Example -
Platform = Environment
("OS")
Msgbox Platform
Logical name is a name
given by QTP while creating an object in the repository to uniquely identify it
from other objects in the application. This name would be used by the QTP to
map the object name in script with its corresponding description in the object
repository. Generally QTP takes caption as a logical name. Example:
Dialog
("Login").WinEdit ("AgentName") – Here “AgentName” & “Login” is
the logical name of the object.
Descriptive programming is
used when we want to perform an operation on an object that is not present in
the object repository. It works as alternative to Object Repository.
When and Where to use
Descriptive programming
1.
One place where DP can be
of significant importance is when you are creating functions in an external
file. You can use these function in various actions directly, eliminating the
need of adding object(s) in object repository for each action [If you are using
per action object repository]
2.
The objects in the
application are dynamic in nature and need special handling to identify the
object. The best example would be of clicking a link which changes according to
the user of the application, Ex. “Logout <xyz>”.
3.
When object repository is
getting huge due to the no. of objects being added. If the size of Object
repository increases too much then it decreases the performance of QTP while
recognizing an object.
4.
When you don’t want to
use object repository at all
There are two ways in which descriptive programming can be used
1.
By Giving The Description
In Form Of The String Arguments: In
this approach, describe an object directly in a statement by specifying property: =value pairs describing the
object instead of specifying an object’s name. The general syntax is:
Dialog
("text: =Login").WinEdit ("Class Name: =WinEdit",
"attached text: =Agent Name :")
2.
By Creating Properties
Collection Object For The Description: Properties
collection also does the same thing as string arguments. The only difference is
that it "collects" all the properties of a particular object in an
instance of that object. Now that object can be referenced easily by using the
instance, instead of writing "string arguments" again and again.
Dp ("Class
Name").value = "WinEdit" ‘Assign property to the object
Set oDp=Dialog ("text: =Login").ChildObjects(Dp) ‘child
object method find enumerated child object
Msgbox oDp.Count ‘displays
number of child object matching given description
oDp(0).set
"ABC1" ‘set value in text box
oDp(1).set
"mercury" ‘set value in text box
CreateObject creates and returns a reference to an Automation object
Syntax: CreateObject (servername.typename [, location])
Arguments
Servername:
The name of the application providing the object. E.g. Internet Explorer, Excel. This is a mandatory parameter.
Typename: The type or class of the object to create.
This is a mandatory parameter
Location: The name of the network server where the
object is to be created. This is an optional parameter.
Example:
‘Creates and returns reference
of the filesystemobject. It is used for performing operations on computer file
system.
Set
myFso=CreateObject ("Scripting.FileSystemObject")
'creates and returns reference of the
Excel object. It can be used for performing operations on Ms-Excel files.
Set
objExcel = CreateObject("Excel.Application")
'creates and returns reference of the
MS Word Object. It can be used for performing operations on Ms-Word documents
Set
objWord = CreateObject("Word.Application")
'creates and returns reference of the
Database Connection. It can be used for Connecting, opening and Closing
databases
Set
objConnection = CreateObject("ADODB.Connection")
'creates and returns reference of the
Database Recordset. It can be used for performing operations on database
tables(Records)
Set
objRecordSet = CreateObject("ADODB.Recordset")
'creates and returns reference of the
Ms-Power point object. It can be used for performing operations on Power point
presentations
Set
objPPT = CreateObject("PowerPoint.Application")
'creates and returns reference of the
Internet Explorer. It can be used for performing operations on Power point
presentations
Set IE
= CreateObject("InternetExplorer.Application")
Yes.
QTP Object Spy helps to view the supported run & test time properties and method
of any object in an open application. Click the pointing hand to select the
object in the application. Object details are displayed in the Object Spy. This
detail includes the test object’s hierarchy tree, its identification properties
and values, and the operations associated with the object. Go to Tools ->
Object Spy or click the Object
Spy button on Tool bar.
There are two ways to Spy the objects in QTP
1.
Thru file toolbar: In the File Toolbar
click on the last toolbar button (an icon showing a person with hat).
2.
Thru Object repository Dialog: In
Object Repository dialog click on the button “object spy…” In the Object spy Dialog click on the button showing
hand symbol. The pointer now changes in to a hand symbol and we have to point
out the object to spy the state of the object. If at all the object is not
visible or windows are minimized then hold the Ctrl button and activate the required window to and release the
Ctrl button.
Object Spy components are as follows -
q Object hierarchy tree
·
Displays the hierarchy of
objects that are related to the object you selected.
q Run-time Object Properties / Run-time Object Methods
·
Displays the run-time
(native) object properties or methods associated with the object selected in
the Object Spy's object hierarchy tree.
q Test Object Properties / Test Object Methods
·
Displays the test object
properties or methods associated with the object selected in the Object Spy's
object hierarchy tree.
·
Properties Tab
·
Displays the properties
and values of the selected object.
·
Properties. Displays the property names for the object that is currently selected
in the Object Spy's object hierarchy tree.
·
Values. Displays the property values for the object that is currently selected
in the Object Spy's object hierarchy tree.
q Methods Tab
·
Displays the methods
associated with the selected object.
·
Methods. Displays the run-time object or test object methods and their
corresponding syntax for the object that is currently selected in the Object
Spy's object hierarchy tree.
·
Description. Describes the method.
QTP Ordinal Identifiers pitfalls are as follows -
·
If two objects are
overlapped on each other than location based object recognition will fail.
·
If only index based
recognition is used your script will work but script execution time will
increase.
In QuickTest, File extension is as
follows –
·
Per test object rep: filename.mtr
·
Shared Object rep: filename.tsr
·
Code file extension id: script.mts
Essentially all
configuration and run functionality provided via the Quick Test interface is in
some way represented in the Quick Test automation object model via objects,
methods, and properties. Although a one-on-one comparison cannot always be
made, most dialog boxes in Quick Test have a corresponding automation object,
most options in dialog boxes can be set and/or retrieved using the
corresponding object property, and most menu commands and other operations have
corresponding automation methods. You can use the objects, methods, and
properties exposed by the Quick Test automation object model, along with
standard programming elements such as loops and conditional statements to
design your program.
A Text Output values
enables to capture or to output text strings displayed in an AUT during run
time. For example, suppose that you want to store the text of any error message
that appears after a specific step in the Web application you are testing. You
can create a text output value while recording or editing your test.
To create a text output
value while recording:
1.
Highlight or display the
text string you want to use for an output value.
2.
Select Insert > Output Value > Text Output
Value. The pointer changes into a pointing hand.
3.
In your application,
click the text string for which you want to specify a text output value. The
Text Output Value Properties dialog box opens.
4.
QTP creates a column
(using logical name of object) in Global DataTable to store output value.
The Step
Generator box enables you to add steps that perform operations, using test
object methods (for tests only), Utility object methods, or function calls. Go
to Insert -> Step Generator or
Press F7 on keyboard to enable Step
Generator dialog box.
In QTP Exceptional handling
is done by using -
1.
Recovery Scenarios
2.
Using “On Error”
statement
In Recovery scenario you have to define -
1.
Triggered Events
2.
Recovery steps
3.
Post Recovery Test-Run
At Script Level you can use the On Error
Resume Next and On Error Go to 0 statements.
A parameter is a variable
that is assigned a value from an external data source at run time. We use
parameterization when we want to change the value of properties at run time. It
replaces a recorded input value in the script. The process by which the scope
of a basic test is expanded by replacing fixed values with Parameters is known
as Parameterization. It greatly
increases the power and flexibility of tests.
Why
Parameterization
·
To test boundary
conditions.
·
To test good data and
"bad" data.
There
are four type of parameter option in QTP.
Data
Table - Enable you to create a
data-driven test (or action) that runs several times using the data you supply.
q Read data from Global Sheet
DataTable("A", dtGlobalSheet) Or
DataTable.value(“A", dtGlobalSheet) Or
DataTable.value(“A”) – Sheet name is optional & is assumed to be
Global sheet in case not provided
q Read data from Action Local Sheet
DataTable("A",
dtLocalSheet) Or
DataTable.value("A",
dtLocalSheet) Or
DataTable(“A",
“Action2”) – Action2 is name of
sheet
Environment Variables -The
Environment variables can have Quick Test generated values or values supplied
from external files. Environment variables are like global variables in other
programming languages which can be accessed through any part of the script. The
values of these variables remain same irrespective of the number of iterations
(unless you change them through scripting). These variables can be shared
across various reusable actions. There are two types of environment variables:
There are two types of Environment
Variables:
1. Built-In: These are the QTP internal
variable. They provide information like the path of the folder where test is
located, the path of the results folder, the name of the action iteration or
the OS version. Go to File ->
Setting -> Environment -> Select
Built In
2.
User Defined : It can be categorized in two
types. Go to File -> Setting -> Environment -> Select User
Defined
2.1 User defined Internal
·
These are the variables
that we define within the test.
·
These variables are saved
with the test and are accessible only within the test in which they were
defined.
·
So how can we define and
use them?
To define them: Environment.Value(“name”)=
“QTP Training”
To call them: Msgbox
Environment.Value(“name”)
2.2 User defined External
·
These are the variables
that we predefine in the active external environment variables file.
These can be created using a list of
variable-value pairs in an external file in .xml format.
1. Random numbers - It enables us to use
random numbers as values in the test. We can specify the range from which the
random number is generated. By default, the random number range is between 0
and 100. Example - Rnd (number)
Syntax:
Msgbox Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Example: Msgbox Int((888888888-111111111 + 1) * Rnd +111111111)
Note -
upperbound is the highest number in the range, and lowerbound is
the lowest number in the range.
4. Test/Action Parameter: Test parameters enable you to use values passed
from your test. Action parameters enable you to pass values from other actions
in your test.
Bitmap checkpoint does a pixel to pixel comparison of an image or part of an image.
Image Checkpoint checks the value of an image in your application like alt text,
destination URL. Note: You create an image checkpoint by inserting a standard
checkpoint on an image object. It is supported only in web environment.
QTP Action
|
Function
|
·
Action is a QTP concept
and it can use QTP features like own Object Repository, Data Table,
checkpoints etc.
·
Actions help make your
Test modular and increase reuse. Example: You can divide your script into
Actions based on functionality like Login, Logout etc.
·
It is slow in
execution.
|
·
Functions is a VB
Script programming concept and do not have their own Object Repository or
Data Table. Functions help in re-use of your code. Ex: You can create a Function in your script to
concatenate two strings.
·
We can’t use
checkpoints in functions, instead of checkpoints we can use validation points
(Loops and Conditional statements)
·
Functions are faster in
execution than Actions
|
Automation
Framework is a set of guidelines like coding standards, test-data handling,
object repository treatment etc. It increases code re-usage, higher
portability, reduced script maintenance cost etc. These are just
guidelines and not rules; they are not mandatory and you can still script
without following the guidelines. But you will miss out on the advantages of
having a Framework. A test automation framework is a set of assumptions,
concepts, and practices that provide support for automated software testing.
Type
of Framework:
q Linear Scripting: - The simplest one,
also known as "Record & Playback". In this approach,
Tester manually records each step (Navigation and User Inputs), Inserts
Checkpoints (Validation Steps) then, Plays back the recorded script in the
subsequent rounds.
Advantages
·
Fastest way to generate
script
·
Automation expertise not
required
·
Easiest way to learn the features
of the Testing Tool
Disadvantages
·
Little reuse of scripts
·
Test data is hard coded
into the script
·
Maintenance Nightmare
q Test Library Architecture Framework:
- In this approach, test scripts are initially recorded by “Record & Playback”
method. Later, common tasks inside the scripts are identified and grouped into
Functions. These Functions are called by main test script called Driver
in different ways to create test cases. Ex: Using the same example as above,
the function for logging in to Flight Reservation will look like .
Function Login()
SystemUtil.Run
"flight4a.exe","","","open"
Dialog("Login").WinEdit("Agent
Name:").Set "Guru99"
Dialog("Login").WinEdit("Password:").Set
"Mercury"
Dialog("Login").WinButton("OK").Click
End Function
Now, you will call this
function in the main script as follows
'Driver
Script
Call Login()
Advantages
·
Higher level of code
reuse is achieved in Structured Scripting
·
The automation scripts
are less costly to develop due to higher code re-use
·
Easier Script Maintenance
Disadvantages
·
Technical expertise is
necessary to write Scripts using Test Library Framework.
·
More time is needed to
plan and prepare test scripts.
·
Test Data is hard coded
within the scripts
q Data-Driven Testing Framework :- In
this approach, while Test case logic resides in Test Scripts, the Test Data is
separated and kept outside the Test Scripts. Test Data is read from the
external files (Excel Files, Text Files) and are loaded into the variables
inside the Test Script. Variables are used both for Input values and for
Verification values. Test Scripts themselves are prepared either using Linear
Scripting or Test Library Framework.
Advantages
·
Changes to the Test
Scripts do not affect the Test Data
·
Test Cases can be
executed with multiple Sets of Data
·
A Variety of Test
Scenarios can be executed by just varying the Test Data in the External Data
File
Disadvantages
·
More time is needed to
plan and prepare both Test Scripts and Test Data
q
Keyword-Driven Framework: - In
this approach, keywords are developed, independent of the test automation tool
used to execute them. Tests can be designed with or without the Application.
The functionality of the application-under-test is documented in a table as
well as in step-by-step instructions for each test. There are 3 basis
components of a Keyword Driven Framework viz. Keyword, Application
Map , Component Function.
Keyword - Keyword
is an Action that can be performed on a GUI Component. Ex . For GUI Component
Textbox some Keywords (Action) would be InputText, VerifyValue, VerifyProperty
and so on.
Application Map- An Application Map Provides Named References for GUI
Components. Application Maps are nothing but “Object Repository’.
Component Function - Component Functions are those functions that actively manipulate or
interrogate GUI component. E.g. - A function would be click on web button with
all error handling, enter data in a Web Edit with all error handling. Component
functions could be application dependent or independent.
Advantages
·
Provides high code
re-usability
·
Test Tool Independent
·
Independent of
Application Under Test, same script works for AUT (with some limitations)
·
Tests can be designed
with or without AUT
Disadvantages
·
Initial investment being
pretty high, the benefits of this can only be realized if the application is
considerably big and the test scripts are to be maintained for quite a few
years.
·
High Automation expertise
is required to create the Keyword Driven Framework.