Quick Test Professional: Introduction: Test Automation Is The Use of
Quick Test Professional: Introduction: Test Automation Is The Use of
Introduction:
Test automation is the use of software to control the execution of tests, the comparison
of actual outcomes to predicted outcomes, the setting up of test preconditions, and other
test control and test reporting functions. Commonly, test automation involves automating
a manual process already in place that uses a formalized testing process.
1) Plug-ins
2) Object Spy
3) Object Repository
4) Record and Play back
5) VB Scripting
6) Check Points
7) Output values
8) Data Table
9) Active Screen
10) Keyword View
11) Expert View
12) Recovery Manager
Plug-ins
Plug-ins are used to make recording more acceptable to a specific application, we use
web plug-ins to automate test cases with respect to web applications. QTP has default
plug-ins for ActiveX controls, web applications and VB objects. This means by default
QTP supports recording Windows and web applications. Plug-ins for other objects, such
as Microsoft .NET objects, is also available. Multimedia plug-ins are also available. In
general, each QTP plug-in is available at an additional cost.
QTP Window:
Object Spy:
Using the Object Spy pointing hand mechanism, you can view the supported properties
and methods of any object in an open application. As you move the pointing hand over
the objects in the application, their details are displayed in the Object Spy. These details
may include the test object's hierarchy tree, its properties and values, and the methods
associated with the object. For methods, the syntax is also displayed. In most
environments, you can choose to view the test object properties and methods or the run-
time (native) properties and methods.
• Open your application to the page containing the object on which you want to spy.
• Choose Tools > Object Spy or click the Object Spy toolbar.
The Object Identification dialog box enables you to set mandatory and assistive
properties, to select the ordinal identifier, and to specify whether you want to enable the
Smart Identification mechanism for each test object.
Mandatory Properties: These are the properties of a class of objects that QTP always
learns to identify these objects at runtime.
Assistive Properties: These are the properties of a class of objects that QTP learns to if it
is not able to differentiate between the two objects in the application using mandatory
properties.
Ordinal Identifiers are used of two or more objects have same set of Mandatory and
assistive properties.
Smart Identification is used when some of the properties of the object are changed from
recording time to run time.
Object Identification Window:
• Choose Tools > Object Identification. The Object Identification dialog box opens.
• Select the appropriate environment in the Environment list. (Web, Standard
Windows,etc.)
• In the Test Object classes list, select the test object class you want to configure.
• In the Mandatory Properties list, click Add/Remove. The Add/Remove Properties
dialog box for mandatory properties opens.
• Select the properties you want to include in the Mandatory Properties list and/or
clear the properties you want to remove from the list.
• Click OK to close the Add/Remove Properties dialog box. The updated set of
mandatory properties is displayed in the Mandatory Properties list.
• In the Assistive Properties list, click Add/Remove. The Add/Remove Properties
dialog box for assistive properties opens.
• Select the properties you want to include in the assistive properties list and/or
clear the properties you want to remove from the list.
• Click OK to close the Add/Remove Properties dialog box. The properties are
displayed in the Assistive Properties list.
In addition to learning the mandatory and assistive properties specified in the Object
Identification dialog box (Tools > Object Identification), QuickTest can also learn a
backup ordinal identifier for each test object. The ordinal identifier assigns the object a
numerical value that indicates its order relative to other objects with an otherwise
identical description (objects that have the same values for all properties specified in the
mandatory and assistive property lists). This ordered value enables QuickTest to create a
unique description when the mandatory and assistive properties are not sufficient to do
so.
• Index. Indicates the order in which the object appears in the application code
relative to other objects with an otherwise identical description.
• Location. Indicates the order in which the object appears within the parent
window, frame, or dialog box relative to other objects with an otherwise identical
description.
• CreationTime. (Browser object only.) Indicates the order in which the browser
was opened relative to other open browsers with an otherwise identical
description
Smart Identification:
Selecting the Enable Smart Identification check box for a particular test object class
instructs QuickTest to learn the property values of all properties specified as the object's
base and/or optional filter properties in the Smart Identification Properties dialog box.
By default, some test objects already have Smart Identification configurations and others
do not. Those with default configurations also have the Enable Smart Identification
check box selected by default.
Any changes you make in the Object Identification dialog box have no effect on
objects already added to the object repository.
Virtual Objects
Complex objects may not be recognized properly by QTP. The Virtual Object concept
was implemented to enable users to add some degree of support for these objects. If an
object is not recorded out-of-the-box, an experienced user may be able to define that
object as a personal virtual object and build a virtual object repository. Assuming that the
required information can be extracted from the object, this allows the users to
successfully record and playback against that object. In practice, this is not always
possible.
You can teach QuickTest to recognize any area of your application as an object by
defining it as a virtual object. Virtual objects enable you to record and run tests on
objects that are not normally recognized by QuickTest.
Using the Virtual object wizard, you define a virtual object by:
• Mapping it to a standard class: Specifies a standard object class from the list.
• Marking its boundaries: Configures the size and location of the virtual object.
Using the crosshairs pointer, you can mark the outline for the virtual object in the
Web page.
• Assigning a parent object: Selects an object in the tree as the parent object.
• Specifying a name and collection: Configures a name and a collection for the
virtual object. You can also choose to define another virtual object.
Object Repository:
Object Repository Stores all the objects learnt by the QTP. One can find object
Repository in Resources > Object Repository. The Object Repository window displays
a tree of all objects in the current component or in the selected action (including all local
objects and all objects in any shared object repositories associated with the selected
action or component).
1) Local. This stored automatically when the test is saved. This can be accessed only
by that particular action.
2) Shared or Global. This has to be explicitly saved. This can be accessed across
Quickest
If the object has any child object QTP will prompt to learn them also. You can select any
option depending upon your need. The object filter window will look like this,
Once the objects are added the objects have to be stored in a Global mode. The shared
repository will have the extension as .tsr
You can manage the shared object repository associations of a selected test using the
Associate Repositories dialog box. The Associate Repositories dialog box enables you to
associate one or more shared object repositories with one or more actions in a test. You
can also remove object repository associations from selected actions, or from all actions
in the test
Steps to Associate Repositories:
• Open the test that has the local objects you want to export.
• Make sure that the Object Repository window is open.
• In the Object Repository window, in the Action box, choose the action whose
local objects you want to export.
• Choose File > Export Local Objects. The Export Object Repository dialog box
opens.
• Select the location in which to save the file, specify the file or attachment name,
and click Save or OK.
After clicking on the playback button all these actions will be played back. During
playback, QTP attempts to identify and perform operations on the same objects, again
using COM.
Recording a Test:
Context Sensitive mode is the default recording mode OF QTP. It performs recording
based on the object repository. It depends only on the objects. Usually the recording
happens on parent – child hierarchy model. Example when you click on Search button on
Google page the script will look something like this:
Browser(“Google”).Page(“Google Search”).WebButton(“Search”).Click.
Analog Recording enables you to record the exact mouse and keyboard operations you
perform in relation to either the screen or the application window. In this recording mode,
QuickTest records and tracks every movement of the mouse as you drag the mouse
around a screen or window.
This mode is useful for recording operations that cannot be recorded at the level of an
object, for example, recording a signature produced by dragging the mouse.
Low Level Recording Enables you to record on any object in your application, whether
or not QuickTest recognizes the specific object or the specific operation. This mode
records at the object level and records all run-time objects as Window or WinObject test
objects. Use low-level recording for recording in an environment or on an object not
recognized by QuickTest. You can also use low-level recording if the exact coordinates of
the object are important for your test.
Active Screen
QTP captures the screen of the application and saves along with the script. The active
screen section highlights the objects in the active screen as the user navigates through the
script so the user knows what object he/she will be performing the action upon.
VB Scripting:
Once the script is generated by recording, we may want to enhance the script to make it
more effective. QTP allows you to do this with the help of VB script language elements.
Following are some of the VB Script language elements that are commonly used.
Command: InputBox.
Displays a prompt in a dialog box, waits for the user to input text or click a button, and
returns the contents of the text box.
Command: MsgBox.
Displays a message in a dialog box, waits for the user to click a button, and returns a
value indicating which button the user clicked.
String Functions:
StrComp: Returns a value indicating the result of a string comparison.
Usage:
A=Strcmp(“Hello”,”Hello”)
InStr: Returns the position of the first occurrence of one string within another
Usage:
val1="welcome to India"
val2="India"
val=InStr(1,val1,val2)
val will have value 12 . This means that the position of the word India in val1 is 12.
Usage:
Val=”appleXballXcatXdog”
Sval=Split(val,”X”,-1)
Sval(1)=ball
Sval(2)=cat.
That is Split command will split the string based upon the delimiter specified.
Usage:
Dim MyVar
MyVar = Now ' MyVar contains the current date and time.
Usage:
MsgBox DiffADate
DateAdd: Returns a date to which a specified time interval has been added.
Usage:
c=a+b
End Function
Call Total(2,3,d)
[statements]
[statements]
End Function
Public
Indicates that the Function procedure is accessible to all other procedures in all scripts.
Default
Used only with the Public keyword in a Class block to indicate that the Function
procedure is the default method for the class. An error occurs if more than one Default
procedure is specified in a class.
Private
Indicates that the Function procedure is accessible only to other procedures in the script
where it is declared or if the function is a member of a class, and that the Function
procedure is accessible only to other procedures in that class.
name
arglist
List of variables representing arguments that are passed to the Function procedure when
it is called. Commas separate multiple variables.
statements
Any group of statements to be executed within the body of the Function procedure.
File handling:
MyFile.Close
Val= MyFile.ReadLine
Val1=MyFile.ReadLine
MyFile.Close
MyConn.Open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Program”+_
"Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb"
msgbox RS("Order_Number").Value
Rs.MoveNext
Wend
Exist: You can enter Exist and/or Wait statements to instruct QuickTest to wait for a
window to open or an object to appear. Exist statements return a boolean value indicating
whether or not an object currently exists. Wait statements instruct QuickTest to wait a
specified amount of time before proceeding to the next step. You can combine these
statements within a loop to instruct QuickTest to wait until the object exists before
continuing with the test.
Example:
counter=1
Wait (2)
blnDone=Window("FlightReservation").Dialog("FlightsTable").Exist
counter=counter+1
If counter=10 then
blnDone=True
End if
Wend
Check Property: Checks whether the specified object property achieves the specified
value within the specified timeout.
Example:
Return Value
A Boolean value. Returns TRUE if the property achieves the value, and FALSE if the
timeout is reached before the property achieves the value.
A TRUE return value reports a Passed step to the test results; a FALSE return value
reports a Failed step to the test results.
GetTOProperty: Returns the value of the specified property from the test object
description.
Return Value: A variant value which will have the inner text of the link “1.2 License
Models”
GetROProperty: Returns the current value of the test object property from the object in
the application.
Return Value: A variant value which will have the current inner text value of the link “1.2
License Models”
ReportEvent : Reports an event to the test results
Example:
or
SystemUtil.Run : You can run any application from a specified location using a
SystemUtil.Run statement
Example:SystemUtil.Run"C:\ProgramFiles\InternetExplorer\IEXPLORE.EXE","","C:\D
ocuments and Settings\Administrator","open"
Step Generator:
The Step Generator dialog box enables you to add steps that perform operations, using
test object methods (for tests only), Utility object methods, or function calls.
When you define a new step, you first select the type of step that you want to add to your
test. You can then select the specific object and method for the step, or the function that
you want the step to use.
After you select the operation for the step, you can specify the relevant argument values
and the location for the return value, if applicable. These values can be parameterized if
required.
Finally, you can view the step documentation or statement syntax and add your new step
or statement to your test or function library.
Test Objects: Enables you to select a test object and method for the step (for tests only).
Utility Objects: Enables you to select a Utility object and method for the step.
Functions: Enables you to select a function for the step from the available library
functions (tests only), VBScript functions, and internal script functions.
Check Points:
QuickTest enables you to add checks to your test. A checkpoint is a verification point
that compares a current value for a specified property with the expected value for that
property. This enables you to identify whether your Web site or application is functioning
correctly.
When you add a checkpoint, QuickTest adds a checkpoint to the current row in the
Keyword View and adds a Check CheckPoint statement in the Expert View. By default,
the checkpoint name receives the name of the test object on which the checkpoint is
being performed. You can choose to specify a different name for the checkpoint or accept
the default name.
When you run the test, QuickTest compares the expected results of the checkpoint to the
current results. If the results do not match, the checkpoint fails. You can view the results
of the checkpoint in the Test Results window.
• Choose Insert > Checkpoint > Standard Checkpoint or click the Insert Checkpoint
or Output Value button and choose Standard Checkpoint. The QuickTest window
is hidden, and the pointer changes into a pointing hand.
• Click the object whose text you want to check. The Object Selection - Checkpoint
Properties dialog box opens.
• Select the item you want to check from the displayed object tree.
The above one is a standard Checkpoint. There are also other check points and the
procedure is same.
DataTable Parameterization:
When you test your application or Web site, you may want to check how it performs the
same operations with multiple sets of data. For example, if you are testing the Mercury
Tours sample Web site, you may want to check that the correct departure and the arrival
cities are selected before you book a particular flight.
To parameterize
1) In the Keyword View, click in the Value cell of the step and then click the
parameterization icon. In the Value Configuration Options dialog box, select the
Parameter radio button. In the Name box, rename p_item to Location.
2) Click Ok.
DataTable.Import: Imports the specified Microsoft Excel file to the run-time Data
Table.
Example:
DataTable.Import ("C:\flights.xls")
DataTable.Export:
Example:
DataTable.Export ("C:\flights.xls")
Recovery Scenario:
The Recovery Scenario Wizard leads you, step-by-step, through the process of creating a
recovery scenario. The Recovery Scenario Wizard contains the following main steps:
You open the Recovery Scenario Wizard by clicking the New Scenario button in the
Recovery Scenario Manager dialog box (Resources > Recovery Scenario Manager).
Defining Trigger Events: The Select Trigger Event screen enables you to define the
event type that triggers the recovery scenario, and the way in which QuickTest recognizes
the event.
• Any error. Any error code that is returned by a test object method.
• Item in list or menu is not unique. Occurs when more than one item in the list,
menu, or tree has the name specified in the method argument.
• Item in list or menu not found. Occurs when QuickTest cannot identify the list,
menu, or tree item specified in the method argument. This may be due to the fact
that the item is not currently available or that its name has changed.
• More than one object responds to the physical description. Occurs when more
than one object in your application has the same property values as those
specified in the test object description for the object specified in the step.
• Object is disabled. Occurs when QuickTest cannot perform the step because the
object specified in the step is currently disabled.
• Object not found. Occurs when no object within the specified parent object
matches the test object description for the object.
• Object not visible. Occurs when QuickTest cannot perform the step because the
object specified in the step is not currently visible on the screen.
The Recovery Operations screen enables you to manage the collection of recovery
operations in the recovery scenario. Recovery operations are operations that QuickTest
performs sequentially when it recognizes the trigger event.
You must define at least one recovery operation. To define a recovery operation and add
it to the Recovery operations list, click next to continue to the Recovery Operation
Screen.
If you define two or more recovery operations, you can select a recovery operation and
use the Move Up or Move Down buttons to change the order in which QuickTest
performs the recovery operations. You can also select a recovery operation and click the
Remove button to delete a recovery operation from the recovery scenario.
Recovery Options:
Close application process. QuickTest closes specified processes. Select this option and
click Next to continue to the Recovery Operation – Close Processes Screen.
Function call. QuickTest calls a VBScript function. Select this option and click Next to
continue to the Recovery Operation – Function Call Screen.
Restart Microsoft Windows. QuickTest restarts Microsoft Windows. Select this option
and click Next to continue to the Recovery Operations Screen.
When you clear the Add another recovery operation check box in the Recovery
Operations Screen and click Next, the Post-Recovery Test Run Options screen opens.
Post-recovery test run options specify how to continue the run session after QuickTest
has identified the event and performed all of the specified recovery operations.
After you specify a test run option in the Post-Recovery Test Run Options Screen, and
click Next, the Name and Description screen opens.
Planning
Before beginning to create a test, you should plan it and prepare the required
infrastructure. For example, determine the functionality you want to test, and decide
which information you want to check during the test run. Before preparing the required
infrastructure, you should spend time analyzing your application and determining which
objects and operations are used by the set of business processes that need to be tested.
You should also determine which operations require customized keywords to provide
additional functionality.
Creating Tests
You create a test either by building an object repository and adding steps manually or by
recording a session on your application. You can create steps using the table-like,
graphical Keyword View using keyword-driven functionality—or you can use the Expert
View, if you prefer programming steps directly in VBScript.
Every test is composed of one or more actions. At its most basic level, each action
contains steps that duplicate the activities that you or another user might perform when
using your application or Web site. You can enhance the testing process by modifying
your test with special testing options and/or with programming statements.
By default, each test begins with a single action. You can organize your test by dividing it
into multiple actions. This is similar to creating separate modules, or logical units, for
testing various parts of your application orWeb site.
When you create your test, you:
• The object repository should contain all the objects that you want to test in your
application or Web site. For more information on building an
As you navigate through your application or site, QuickTest graphically displays each
step you perform as a row in the Keyword View. A step is something that causes or makes
a change in your site or application, such as clicking a link or image, or submitting a data
form. In the Expert View, these steps are displayed as lines in a test script (VBScript).
The Documentation column of the Keyword View also displays a description of each step
in easy-to-understand sentences
A checkpoint checks specific values or characteristics of a page, object, or text string and
enables you to identify whether or not your Web site or application is functioning
correctly.
Broaden the scope of your test by replacing fixed values with parameters. When you test
your site or application, you can parameterize your test to check how your application
performs the same operations with different data. You may supply data in the Data Table,
define environment variables and values, define test or action parameters and values, or
instruct QuickTest to generate random numbers for current user and test data. When you
parameterize your test, QuickTest substitutes the fixed values in your test with
parameters. When you use Data Table parameters, QuickTest uses the values from a
different row in the Data Table for each iteration of the test or action. (Each run session
that uses a different set of parameterized data is called iteration.)