Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

QTP Online Training

Download as pptx
Download as pptx
You are on page 1of 86

Introduction To Automation

1 Confidential
Overview of Automation

 What is Automation?
 Automation is a process of executing a task with very less/no manual
interaction with the help of tools/software
 Automation takes less interactive time and effort to execute tasks that
require repeatability.
 Test Automation facilitates executing a test cycle for an application
with less/no manual interaction.
 Why to Automate?
 Executing tests repeatedly for each test cycle is tedious and
cumbersome.
 Writing script/program that can automate the testing tasks reduces
time and effort to execute a test cycle drastically.

2 Confidential
Automation Advantages

 One-time effort to write scripts


 High reusability when repeating tasks
 Faster to execute each test cycle
 Reliable in performing repeatable tasks
 Cost-effectiveness
 To minimize mistakes in test execution
 Allows to run same test in multiple instances at the same time
to produce load on an application
 Upgrades to an application can be easily tested with minimal
changes to existing scripts

3 Confidential
Limitations of Automation

 Automation requires upfront investment


 If there is mistake in automation that will repeat in
subsequent tests.
 The automation script needs to be tested before executing
tests which involves extra effort.
 In some cases the automation may not be possible/feasible.
 For exp: colors of the objects, based on functionality which changes
dynamically.
 Where tool doesn’t recognize the object.
 It may not be possible in cross-platform applications.

4 Confidential
Test Automation types

 Record & Playback


 To automate tests (a set of tasks), one can use record-playback mechanism,
which is available with most of the GUI Automation Tools.
 Partial Recording & Partial Scripting
 Record a script using a recorder.
 The generated script may not run dynamically.
 Script needs to be edited to meet the testing needs. (Example: Testing Login screen
with 10 different user ids. For this scenario, you can record for one user id only. To make use of the
same script for other user ids, you need to do some scripting.)

 Complete Scripting
 Automating scripts for large applications is complex
 With the record-playback mechanism, there is no flexibility
 By scripting, more meaningful tests can be automated
 Scripts maintenance is easier

5 Confidential
The Five Concepts in Automation

1. Record & Playback


2. Object Identification
3. Verifications
4. Data Driving
5. Exception Handling

6 Confidential
Test Automation Tools

 QuickTest Professional (HP)


 Rational Functional Tester (IBM Rational)
 SilkTest (Micro Focus International)
 TestPartner (Micro Focus International)
 TestComplete (Automated QA)
 Selenium (Open Source)
 Watir(Open Source)

7 Confidential
Introduction To QuickTest Professional

8 Confidential
What is QuickTest Professional?

 QuickTest Professional is a leading functional testing tool


from HP
 It allows users to record and run actions on a web or
desktop application
 It is mainly used for Regression Test Automation
 It uses a scripting language built on top of VBScript
 It can automate UI and Non-UI based Applications

9 Confidential
Supported Environments and Programs

Application Technologies
 Virtualization Technologies
 .Net  Siebel
 VMware workstation 5.5
 Activex  Standard Windows
 Citrix MetaFrame Presentation
 Delphi  Stingray
Server 4.5
 Flex  Terminal Emulator
 VMWARE ESX 3.0.1
 Java  Visual Basic
 Microsoft Virtual PC 2004
 Oracle  Visual Age
 Microsoft Virtual PC 2007
 PeopleSoft  Web
 Microsoft Office
 Power Builder  Web Services
 Microsoft Excel
 SAP  WPF
 Microsoft Query

 Web Browsers
 Internet Explorer 8.0

 FireFox 3.5

 NetScape 9.0

10 Confidential
Testing Process in QTP

 Planning:-
 Before beginning to create a test, you should plan it and prepare the
required infrastructure. For example, determine the functionality you
Planning want to test, and decide which information you want to check during the
test run.

 Creating Tests:-
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
Running Tests functionality—or you can use the Expert View, if you prefer programming
steps directly in VBScript.

 Running Tests:-
Analyzing Results  Run your test to check your site or application. Run your test to debug it.
You can control your run session to help you identify and eliminate defects
in your test.

 Analyzing Results:-
 After you run your test, you can view the results. You can view a summary
of your results as well as a detailed report. You can also capture still
images or movies of your application as it is being tested.

11 Confidential
QuickTest Professional – Glance

12 Confidential
Add-in Manager

 By default QuickTest Support Activex,


Visual Basic, Web, Windows

 If you have installed QuickTest add-ins, you


can specify which add-ins to load at the
beginning of each QuickTest session.
Loading the relevant add-in enables
QuickTest to work with the corresponding
environment.

 You can select which add-ins to load for


the current session of QuickTest. To
maximize performance and object
identification reliability, load only the add-
ins you need.

13 Confidential
Keyword View
 The Keyword View enables you to create and view the steps of your test in a
keyword-driven, modular, table format.
 Each step is automatically documented as you complete it, enabling you to view a
description of your test in understandable sentences.
 Working in the Keyword View does not require any programming knowledge.
 This view is useful for Manual Testers to understand the script easily.

14 Confidential
Expert View
 QuickTest displays each operation performed on your application in the form of a
script, comprised of VBScript statements.
 For each object and method in an Expert View statement, a corresponding row
exists in the Keyword View.
 In the same manner the steps which are added in Keyword View will automatically
generates script statements in Expert View.
 To work with Expert View the tester should have familiarity with VBScript
 The objects hierarchy is separated by a “.”, and the hierarchy structure is from
Parent to child.

15 Confidential
Object Hierarchy in Expert View and Keyword View

16 Confidential
Active Screen
 Active Screen captures the application screenshot in recording time
 Based on the selected step in the expert view or keyword view, the active screen
highlights the selected step object
 It gives a facility to add Check Points / Objects
 It also gives the source code for web applications

17 Confidential
Datatable

 Datatable is used to store the data that can be used by the parameterized scripts
 By default two sheets (Global and Action1) are available for a new test
 For each Action added in a Test, a corresponding sheet will get added with same
Action name
 The Global Sheet is to manage Test iterations and the Action Sheets are to manage
corresponding Action Iterations

18 Confidential
Debug Viewer
 Debug viewer provides assistance when debugging the Tests
 The assistance is in the form of giving a facility to evaluate statements, Display and
modify the variable values in Script runtime
 There are three tabs in Debug Viewer
 Watch - Displays the current value of the added variable
 Variable - Displays current value of all available variables till the executed step
 Command - Provides facility run lines of script to set or modify the current value
of a variable

19 Confidential
Information

 It checks and displays a list of syntax errors in your test or function library scripts.
 Ctrl+F7 is the key to check for the syntax errors
 It automatically check for the syntax errors when the user navigates from expert
view to keyword view
 It automatically locates the error by double click on the syntax error displayed in the
information pane
 It displays the error generated statement in the tool tip for every syntax error in the
Information pane

20 Confidential
Missing Resources

 It displays the list of resources that are specified when designing the test and missed
out / cannot be found by QTP when the Test is opened again for any purpose.
 Missing resources can include calls to missing actions, missing function libraries,
missing recovery scenarios, missing environment variable XML files, unmapped
shared object repositories, and parameters that are connected to shared object
repositories.

21 Confidential
Available Keywords
 This displays all available keywords in the test or associated to the test.
 A key word is an object name / function name
 It gets the all object names from object repository window and all function names
from script and libraries
 It provides a facility to generate the script automatically by dragging the keywords.

22 Confidential
Resources

 Tests and actions are associated with


resources such as function libraries, recovery
scenarios, and object repositories.
 The Resources pane enables you to add,
remove, and manage all of the resources in
your test.

23 Confidential
Test Flow

 The Test Flow pane displays all the calls to actions in the current test and the
order in which they are run.
 It gives a facility to modify the Action Run Order
 From the Test Flow pane, you can display test, action, and action call properties,
manage actions and change their order in the test, work with the object
repository, and run specific actions.

24 Confidential
ToDo
 The ToDo pane is to create, view, and manage TODO tasks.
 A TODO task is anything that needs to be done in a test, such as providing
information relevant for handing over a testing document, or adding a reminder to
yourself to add steps that test a new page in your application.
 This is more useful when reviewing the Test

25 Confidential
Record & Playback

26 Confidential
Recording
 Recording is a process of capturing operations that are performed by user on the
application.
 QTP captures every operation and generates a vbscript step in expert view.
 A step is anything a user does that changes the content of a page or object in the
application
 There are three recording types in QTP
1. Normal Recording
 This recording mode is the default recording mode. Normal recording mode
records the objects in your application and the operations performed on them.
2. Analog Recording
 Enables you to record the exact mouse movements and keyboard operations you
perform in relation to either the screen or the application window.
3. Low Level Recording
 This recording mode is 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.

27 Confidential
Differentiate Recordings Modes
Normal Recording Analog Recording Low Level Recording
Records Object information based on test Records Mouse Movements respect to Records all objects as window or win
object model. window or screen. objects.

Records Keyboard i/p’s. Records Keyboard i/p’s Records Keyboard i/p’s Records mouse clicks
with co-ordinates.
Records Mouse Clicks. Records Mouse clicks.
Records object information in the form of
Object Information will store in object It can’t record object information. window or winobjects.
repository.
Not possible to edit the script after recording Possible to edit the scripts after recording
Possible to edit the scripts after recording with in QTP. with in QTP.
with in QTP.
Alternative mode for recording signatures. Recorded steps may not run correctly on all
Recording a signature is not possible objects.
When we are recording with respect to
Recorded steps will run correctly on all window, the window object information will supports the following methods for each test
objects. stores in object repository. object:

Support all methods for every object. Analog recording and lowlevel recording WinObject test objects:
This is Default Recording method. require more disk space than normal Click, DblClick, Drag, Drop, Type
recording mode.
Window test objects: Click, DblClick, Drag,
Drop, Type, Activate, Minimize, Restore,
Maximize

28 Confidential
Choosing a Recording Type

 Normal Recording mode is default and suggested to use always.


 Analog and Low level recording modes are suggested to use only in the failure of
normal recording
 Analog Recording 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 is 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.

Note:-
 You cannot edit Analog Recording steps from within QuickTest.
 Steps recorded using Low Level Recording mode may not run correctly on all
objects.

29 Confidential
Understanding Recorded Script

 A recorded step will have 3 parts


 Object – Where to perform the operation
 Operation – What to do on the object
 Data – Value to insert in the object

Data

Object Operation

30 Confidential
Understanding Result Window

Filter Result
Done
Fail
Pass
Warning

Summary of step
status

31 Confidential
Object Identification

32 Confidential
Object Identification Introduction

 QTP captures the user actions when recording. But It also captures the object
information on which the user is performing the actions.
 The object information is further used to identify the objects when running the
scripts
 QTP follows specific principles to record and use the object information.
 QTP records the object information based on its Test Object Model (TOM)
 The Test Object Model is a large set of object types or classes configured with a
list of identification properties that QuickTest can learn about the object, a sub-
set of these properties that can uniquely identify objects of that class
 QTP stores the object information in a place called Object Repository
 The object information will be stored with a logical name (Tag Name)
 This logical name will be used in the script to do operations on the object

33 Confidential
Object Identification in RunTime and Recording Time

Object Identification can be classified in to two types


1. Record Time object identification: To capture unique description in QTP
2. Run Time object identification: To find unique object in application

During Runtime During Record time


Step1:- Look for class and logical Step1:- QuickTest gets information
name in script about object from OS. Ex. Class
Step2:-Search for the same class Step2:- Identifies what properties
and logical name in object need to be recorded based on
repository TOM
Step3:-Identify the object in Step3:- Creates an unique
application using properties of description based on TOM and
the object that stored in stores in object repository as a
recording time. test object.

34 Confidential
Object Repository (OR)

 Object Repository is the mind of QTP


 The objects which are recorded using any recording type will be stored in OR
 The objects which are there in OR called as Test Objects
 There are Three sections in object repository
1. Test Objects :- Displays the list of all objects in Object Repository
2. Object Properties :- Displays the recorded properties of a selected Test
Object
3. Checkpoint and Output Objects :- Displays the list of check points and
output values which are used in the script

Using OR we can

1. Add objects
2. Delete objects
3. Modify Properties
4. Export objects to a shared file

35 Confidential
Object Repository Window

Test
Objects List

Checkpoint and
Output Objects

Object
Properties

36 Confidential
Object Spy
 Object Spy enables you to view the native properties and operations of any
object in an open application, as well as the test object hierarchy, identification
properties, and operations of the test object that QuickTest uses to represent
that object.
 The native properties are assigned by application provider
 QuickTest does not show all the properties of an object
 If shows the properties which are defined in Test Object Model
 Object Spy uses pointing hand mechanism. To display properties of any object
you just need to point the object
 After clicking on point hand symbol, hold CTRL key to navigate using normal
mouse pointer
 Use Right click to stop spying

37 Confidential
Object Spy Window

Native Properties Native Operations

Identification Properties Identification Operations

38 Confidential
Test Object Model

 The Test Object Model is a large set of object types or classes configured with a list of
identification properties that QuickTest can learn about the object, a sub-set of these
properties that can uniquely identify objects of that class
 A test object is an object that QuickTest creates in the object repository to represent
the actual object in the application. This will be created by using the configured
identification properties in TOM.
 A run-time object is the actual object in your application on which methods are
performed during the run session.
 QuickTest has a predefined set of properties that divided in to two types
 Mandatory Properties
 Assistive Properties
 If these properties have not created an unique description QuickTest uses an ordinal
identifier to create a unique description.
 An ordinal identifier is a number that will be assigned for an object based its ordered
sequence / located place in the application.

39 Confidential
So how QTP creates unique description for an object?

 QuickTest Identifies object class and maps to any appropriate test object class
available in TOM.
 For every test object class in TOM have configured with specific Mandatory ,
Assistive properties and Ordinal Identifiers.
 Records all available mandatory properties and checks for unique description
 If recorded description is unique then this description will be moved to OR
 If it is not unique, then QTP will record assistive properties to create unique
description
 QuickTest learns one assistive property at a time and stops as soon as it creates a
unique description for the object
 If the combination of all defined mandatory and assistive properties is not
sufficient to create a unique test object description, QuickTest also records the
value for the selected ordinal identifier.

40 Confidential
Object Identification Configuration

Add-in
Environments Preconfigured
mandatory and
assistive properties

Available Test Object


Ordinal Identifiers
Classes

41 Confidential
Object Repository Types

The captured objects can be stored in two types of object repositories


1. Local
2. Shared

 Local objects are saved locally with the action, and can be accessed only from that
action.
 A shared object repository stores test objects in a file that can be accessed by
multiple tests (in read-only mode).
 A Local Object Repository can be exported to a Shared Object Repository to use it
for multiple tests.

42 Confidential
Local and Shared Object Repository
Local
 As you record operations on objects in your application, QuickTest automatically
stores those objects in the corresponding local object repository.
 QuickTest adds all new objects to the local object repository even if one or more
shared object repositories are already associated with the action.
 For every new action added in a test, a new corresponding local object repository
will be created in the test.
 The extension for local object repository is .bdb

Shared
 Shared object repositories can be created in two ways
 From Object Repository Manager
 By exporting objects from local object repository
 QTP can use multiple shared object repositories for one action/test in readable
format.
 Editing of a shared object repository only by using object repository manager
 The extension for shared object repository is .tsr

43 Confidential
When to use Shared / Local Object Repository types?

Shared
 You have several tests that test elements of the same application, interface, or set
of objects.
 You expect the object properties in your application to change from time to time
and/or you regularly need to update or modify test object properties.
 You often work with multi-action tests and regularly use the Insert Copy of Action
and Insert Call to Action options.
 You are creating tests using keyword-driven methodologies (not using record).

Local
 You have only one, or very few, tests that correspond to a given application
interface, or set of objects.
 You do not expect to frequently modify test object properties.
 You generally create single-action tests.

44 Confidential
Object Repository Manager
 Object Repository Manager is used to create and modify Shared Object
Repositories.
 Multiple instances of Object Repositories can be created and managed.
 It has the capability to Compare & Merge of OR’s using Compare & Merge Tools.

Multiple instances of
Object Repositories

45 Confidential
Object Repository Comparison Tool
 The Object Repository Comparison Tool compares two OR’s and displays the
differences in their objects, such as different object names, different object
descriptions, and so on.
 It can compare only two OR’s at a time.

46 Confidential
Object Repository MergeTool
 The Object Repository Merge Tool merges two OR’s and gives the merged
repository.
 It can merge only two OR’s at a time.

47 Confidential
Virtual Objects
 A virtual object is defined by user in QuickTest to recognize any area of the
application as an object. Virtual objects enable you to record and run tests on
objects that are not normally recognized by QuickTest.
 QuickTest does not support virtual objects for analog or low-level recording.
 For example, 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.
 The Virtual Objects are useful to differentiate the objects by creating virtual
objects for every link.

Gmail Images Blogs Sites

48 Confidential
Verification / Check Points

49 Confidential
CheckPoint and Types

 A check point is a step that compares an expected value specified in the script to
an actual value in the application
 When you run the test, QuickTest compares the expected results of the checkpoint
to the actual results. If the results do not match, the checkpoint fails.

Types
• Standard Check Point :- Checks properties of an object
• Page Check point :- Checks properties of a page
• Image Check point :- Checks properties of an image
• Table Check point :- Checks cell data of a webtable
• Text / Text Area Check point :- Checks text on an specified object / area
• Bitmap Check point :- Checks Bitmap of the specific object / area
• Database Check point :- Checks Database
• Accessibility Check point :- Checks web site developed under w3c guidelines
• Xml Checkpoint :- Checks the Data content in xml files

50 Confidential
checkpoints support for each Add-in Environment

Checkpoint Type Web Standard Windows VB ActiveX

Standard S S S S
Image S NS NS NS
Table S S (WinListView) S (VbListView) S

Text S (Page, Frame and ViewLink) S S S

Text Area NS S S S
Bitmap S S S S
Accessibility S NS NS NS
XML (From S NA NA NA
Application)
XML (From S S S S
Resource)
Page S NA NA NA
Database S S S S

S: Supported
NS: Not Supported
NA: Not Applicable

51 Confidential
O
n Standard CheckPoint Configuration
Note: If you apply a Standard Check
A Point on Page, Image and Table
n automatically that check point
y O will convert into Page Checkpoint,
n Image Checkpoint, Table
O Checkpoint
b P
j a
e g
c O
e n
t
O T
O b
n a
j b
e l
I c
m e
t
a
g O
e b
j
O e
b c
j t
e
c
t
52 Confidential
Text, Bitmap and Accessibility CheckPoint Configuration

 A Text Check point is  Accessibility checks for web  We can check the
similar to Text Area standards complete bitmap or a part
checkpoint.  It can be applied only on of the bitmap.
 It checks for the text Web Page  It may not give the same
existence in the  To modify the verifications result when you execute
application we have to go Options the script in different
Web Advaned screen resolutions.

B
T i
e t
x Accessibility
CheckPoint
M
t a
p
C
C
h h
e e
c c
k k
P Current P
o Verifications o
i i
n
n t
t
53 Confidential
Database CheckPoint Configuration

Select
How you
want to Select which cells need
Specify to be Checked
SQL
Statement

Specify
DSN

Specify
SQL
Statement

54 Confidential
XML CheckPoint Configuration

 XML Checkpoint is to check


Browse the XML data in an XML file
File
 When you have the XML file
in your local drives then you
can use XML Checkpoint
from Resource option
 When your getting an XML
file in a browser by
navigating an URL then you
can use XML file from
Application
Attributes & Values
for an Element

XML File Data


Hierarchy
55 Confidential
Output Values

 An output value is a step in which one or more values are captured at a specific
point in your test and stored in QTP storage locations. The values can later be used
as input at a different point in the run session.
 The storage locations for QTP is Datatable, Environment and Action Parameters

• Standard Output Value :- Get property values of an object


• Page Output Value :- Get property values of a page
• Table Output Value :- Get cell data of a webtable
• Text / Text Area Output Value :- Get text on an specified object / area
• Database Output Value :- Get Database values
• Xml OutputValue :- Get Data content in xml files

56 Confidential
Output values support for each Add-in Environment

Output Value Category Web Standard Windows VB ActiveX


Standard S S S S
Page (Standard) S NA NA NA
Table (Standard) S NA NA S
Text S (Page, Frame and ViewLink) S S S
Text Area NS S S S
Database S S S S
XML (From Application) S NA NA NA
XML (From Resource) S S S S

S: Supported
NS: Not Supported
NA: Not Applicable

57 Confidential
Synchronization

 A synchronization point is to make a timing adjustment between QTP and


Application.
 When you run tests, your application may not always respond with the same
speed. it might take a few seconds:
 for a progress bar to reach 100%
 for a status message to appear
 for a button to become enabled
 for a window or pop-up message to open
 To solve these type of problems 4 types of sync methods are useful based on the
situation
 Default Synchronization Time in Test Settings
 Wait(seconds)
 Object.WaitProperty “Property Name”, “Property Value”, “Wait Time in MS”
 Object.Exist(TimeOut)

58 Confidential
How Synchronization Works?

Without synchronization point With synchronization point

t
ri p

t
T

rip
U

T
Sc

U
A

Sc
Run script

A
Run script

Inputs data Accepts


to AUT input Inputs data Accepts
to AUT input

Attempts Sends data to


next step database server Waits Sends data to
database server
Script Waits for
fails server;
cannot
continue

Continues and
Continues completed in
same time.

59 Confidential
Parameterization / Data Driving

60 Confidential
Parameters and Types

 A parameter is a variable that is assigned a value from an external data source or


generator.
 Replacing a Value with a Parameter is called as parameterization
 The Data Driven scripts can be created by using the concept of Parameterization

Four Type of Parameters available in QTP

 Test/Action – To pass values from an action/test to another action/test


 Environment – To use the current environment values in the script
 Datatable – To create a Data-Driven Tests that runs several iterations with deferent data
 RandomNumber – To generate Random Number in a specific range for scripts

61 Confidential
Iterations

 A single execution of a set of instructions that are to be repeated is called as an


iteration
 There are two types of Iterations for a Test
 Test Iteration
⁻ A single execution of all Actions in a Test
 Action Iteration
⁻ A single execution of an Action in a Test
 Action iterations are depends on the number of rows filled up in its Action data
sheet.
 Test iterations are depends on the number of rows filled up in Global data sheet.
 A data table row can be filled up with null data
 By default in QTP the data table rows are in dim black color. If you enter any data
in a row automatically the row line color will become black. That color indicates
row is having some data.

62 Confidential
Datatable Parameterization
Browser("MakeMyTrip").Page("MakeMyTrip").WebList("from").Select "Hyderabad"
Browser("MakeMyTrip ").Page("MakeMyTrip").WebList("to").Select "Delhi"

This code is to select Origin and Destination of a travel trip. To make a reuse of this code for other travel
trips selection then the datatable parameters should be replaced in place of values.

After adding Datatable Parameters Column Name Sheet Name


Browser("MakeMyTrip").Page("MakeMyTrip").WebList("from").Select Datatable("Origin", "Global")
Browser("MakeMyTrip").Page("MakeMyTrip").WebList("to").Select Datable("Destination", "Global")

63 Confidential
Actions
 Action is a part of the test. It helps to divide a test into logical units, such as
the main sections of a Web site, or specific activities that you perform in
your application.
 An action consists of its own test script, including all of the steps recorded in
that action, and any objects in its local object repository.
 If a test is handling more functionalities / modules its better to use multiple
actions. Splitting functionality into actions avails reusability of actions in
other tests.

 Non Reusable Actions / Normal Actions


– an action that can be called only in the test with which it is stored, and can be
called only once.
 Reusable Actions
– an action that can be called multiple times by the test with which it is stored
(the local test), as well as by other tests.
 External Actions
– a reusable action stored with another test. External actions are read-only in the
calling test, but you can choose to use a local, editable copy of the Data Table
information for the external action.

64 Confidential
Actions Reusability

* Indicates Reusable Actions


** Indicates External Actions

65 Confidential
Action Parameterization

 Action Parameters are useful to pass values from one action to another action
while calling an Action
 Two types of parameters available for every action
 Input Parameters

- To pass the value in to an Action


 Out Put Parameters

- To get the value in from an action

Defining and Using Action Parameters


1. Edit  Action  Action Properties  Parameters Tab
2. Click on “+” button with respect to paraneter
3. Give the Parameter Name, type and Value
4. Click on OK
5. In script where ever you want to use Action parameter, Replace the value with
Paramaeter(“Paramater Name”)

66 Confidential
Action Parameters Configuration

Parameter Value types


 String
 Boolean
 Date
 Number
List of Input Parameters  Password
 Any

List of Output Parameters

67 Confidential
Environment Parameters

 Environment Parameters are useful when an application needs to be tested in


different languages / operating systems / browsers
 These parameters can be accessed across the test
 Three types of Parameters
 Built In

- Variables that gives the information about present Test / Computer


 User Defined Internal

- Variables that are defined by an user. These variables are saved with the test
and are accessible only within the test in which they were defined.
 User Defined External

- Variables that are defined by an user in an external environment file. These


variables are saved with that external file and can be shared with any
number of tests in Read-Only mode.

68 Confidential
Environment Parameters Configuration
Built-In Variables

User Defined Variables

Note:-
 The variables which are in blue external environment file
color are defined in external file

69 Confidential
Random Number Parameters
 Random number parameter is to generate
random numbers
 The range can be specified in Parameter Options
dialog

 Random Numbers configuration has 3 options


 Specify Numeric Range

- This will generate Random Number in a


specific range
 Specify Name

- Assigning a name to a random parameter


enables you to use the same parameter
several times in your test.
 Iteration based Random Number Generation
 For Each Action
 For Each Test
 Once per Entire Test

70 Confidential
Action vs Function
Action Function
Action is Specific to QTP Function is specific to VBScript

Action will have own local repository, Datatable Functional will not have anything to it.
and any other resources

Action run only in QTP. Functions can run out side of QTP

Action will not return any value Function returns the value

Action doesn’t supports arrays and objects in Function support arrays, objects as inputs.
action parameters.
Can call a function from an action Not possible to call an action in the function

Action have input and output parameters Function have byval and byref parameters

If you call an action from another action you’ll find If you call a function from another function or an
script, Datatable, Object repository in that called action you don’t find anything for that function
action
QTP is mandatory to modify an action No need to have QTP to modify function

71 Confidential
Recovery Scenario Manager / Exception Handling

72 Confidential
Recovery Scenario Manager Introduction
 We may get some unexpected events, errors, and application crashes during a run
session which will disrupt run session
 QTP provides a facility called Recovery Scenario Manager to make recovery scenarios
to recover from these type of errors
 The Recovery Scenario Manager provides a wizard to define Recovery Scenarios
which includes a definition of an unexpected event and the operations necessary to
recover the run session
 Recovery scenarios are saved in recovery scenario files with extension of .QRS. A
recovery scenario file is a logical collection of recovery scenarios, grouped according
to your own specific requirements.
 A Recovery Scenario Consists
 Trigger Event - The event that interrupts your run session.
 Recovery Operations - The operations to perform to recover from the error and
continue the running
 Post-Recovery Test Run Option - From which point to run the test after the
recovery operations have been performed

73 Confidential
Trigger Event Types
 Popup Window
- This is useful when an application is giving unwanted popup dialogs which
interrupts the test run. QuickTest can detect this window and activate a defined
recovery scenario to continue the run session.
 Object State
- An object is at specific state that generates the error. For example, a specific
button in a dialog box may be disabled when a specific process is open.
QuickTest can detect the object property state of the button that occurs when
this problematic process is open and activate a defined recovery scenario to
close the process and continue the run session.
 Test Run Error
- A step is failed in a test. Test Run Error Recovery Scenario gives a facility to create
recoveries based on the error which we got in QTP during test run.
 Application Crash
- The Application is crashed during the test run which interrupts the test run.
QuickTest can detect this application crash and activate a defined recovery
scenario to continue the run session.

74 Confidential
Recovery Operations

 The Recovery Operations are will be specified based on the trigger event.
 These will be performed after QTP detects an error and trigger event
 4 Types of recovery operations available for every trigger event
1. Keyboard / Mouse Operations
 QuickTest simulates the keyboard and mouse operations for clicking / typing keys.
This is useful when there is a single step to be performed.
2. Close Application Process
 QuickTest closes the specified process. This is useful to close an unwanted process
which blocks the script execution.
3. Function Call
 A function call which is stored in a function library. This is useful when there are
multiple operations to be performed.
4. Restart Microsoft Windows
 Restarts the OS. This is useful when you get the errors because of any pending
restart.
 You must configure the computer on which the test or component is run to
automatically log in on restart.

75 Confidential
Post Recovery Operations
 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.
 6 Types of Post recovery operations available
1. Repeat current step and continue
 The current step is the step that QuickTest was running when the recovery scenario was triggered. This
is useful when your recovery operation is clearing the disturbance to run the step.
2. Proceed to next step
 Skips the step that QuickTest was running when the recovery scenario was triggered. This is useful
when your recovery operation is providing some alternative for that step.
3. Proceed to next action or component iteration
 Stops the current action and begins the next iteration. This is useful when there is no facility to
continue the run for that particular action. Usually it follows with close application process.
4. Proceed to next test iteration
 Stops the current test iteration and begins the next iteration. This is useful when there is no facility to
continue the run for that particular test. Usually it follows with close application process.
5. Restart current test run
 Stops and re-runs the current test. This is useful when there is no facility to continue the run for that
particular test. This follows with Restart Microsoft windows.
6. Stop the test run
 Stops running the test or component. This is useful when there is no facility to continue the run for that
particular test. This follows with Restart Microsoft windows.

76 Confidential
Creating a Recovery Scenario

Open Recovery
Scenario File

New Recovery Edit Recovery


Scenario Scenario

Recovery scenario wizard opens by clicking on


New Recovery Scenario button

Go to Resources  Recovery Scenario Manager

77 Confidential
Configuring Recovery Scenario by Trigger Event
O
b
j
P e
o c
p t
S
u t
Specify p a
Window Title Specify
t
Object State
e

A
T p
e p
l
s
i
t c
R a
u t
n i
o
E n
Specify Error C Specify
r Process Name
Type r r
a
o s
r h
78 Confidential
Configuring Recovery Scenario
R
e
c P
o o
v s
e t
r
y R
e
O c
p o
e v
r e
a r
t y
i
o
n

S
c
e A
n d
a d
r
i t
o o

N T
a e
m s
e t

79 Confidential
Functions & Libraries
 An user define function is a group of statements that encapsulates an activate into a
keyword (Function name)
 User-defined functions enables you to create shorter tests, easy design, read, and
maintain.
 QTP is giving a facility to register the functions for any test object
 A registered function can either override the functionality of an existing test object
method or be registered as a new method for a test object class
 We can define and store functions in function libraries or in QTP Actions
 QTP is giving a facility to develop function libraries with the extension .QFL
 A function library is a Visual Basic script containing VBscript functions, subroutines,
modules, and so forth.
 We can use .VBS, .TXT, .QFL files as function libraries
 We can associate the function libraries to a QTP Test and can use the functions in
across the test
 The functions which are defined in a QTP Action can be called only in the same Action
 The function which are defined as private in function libraries can be called only with
in that function library

80 Confidential
Creating Functions & Libraries
 In VBScript Functions are usually called as Procedures.
 There are Two types of procedures
1. Function Procedures
2. Sub Procedures (Sub Routines)
 Function and Sub procedures will have a series of VBScript statements.
 Functions can return value where as Sub doesn’t return a value. This is the main
difference between.

Creating Function Procedure Creating Sub Procedure Creating Function Library


‘ Creating function procedure ‘ Creating Sub procedure Step1:- Got to File  New 
Function Library
Function Demo_Add(a,b) Sub Demo_Add(a,b,c)
Step2:- Write all of your functions
Demo_Add=a+b c=a+b in it
End Function End Sub Step3:- Save it
‘Calling Function procedure ‘Calling Function procedure Using Function Library to a Test
Msgbox Demo_Add (2,3) Demo_Add 2,3,x File  Settings  Resources tab
Msgbox x Click on (+) button and select the
saved file

81 Confidential
Regular Expressions

82 Confidential
What is a Regular Expression?
 A Regular Expression is a string that provides a complex search phrase.
 Phrase is an expression consisting of one or more words.
 Regular expressions enable QuickTest to identify objects and text strings with varying
values.
 By using special characters, such as a period (.), asterisk (*), caret (^), and brackets
([ ]), we can define the Regular Expression conditions of a search.
 We can specify Regular Expressions in Object Repositories, Checkpoints,
Programmatic Descriptions and for VBScript Logics.
 VBScript provides an object REGEXP to define and use regular expressions in script

Notes:
 You can use regular expressions only for values of type string.
 When any special character in a regular expression is preceded by a backslash (\),
QuickTest searches for the literal character.

83 Confidential
Creating Regular Expressions

 A backslash (\) can serve two purposes. It can be used in conjunction with a special character to
indicate that the next character be treated as a literal character. For example, “\z” matches z.
 A period (.) instructs QuickTest to search for any single character (except for \n). For example
“welcome.” matches welcomes, welcomed, or welcome followed by a space or any other single
character. A series of periods indicates the same number of unspecified characters.
 Square brackets instruct QuickTest to search for any single character within a list of characters. For
example, to search for the date 1967, 1968, or 1969, enter: “196[789]”
 When a caret (^) is the first character inside square brackets, it instructs QuickTest to match any
character in the list except for the ones specified in the string. For example: “[^ab]” matches any
character except a or b.
 To match a single character within a range, you can use square brackets ([ ]) with the hyphen (-)
character. For instance, to match any year in the 1960s, enter: “196[0-9]”
 An asterisk (*) instructs QuickTest to match zero or more occurrences of the preceding character.
For example: “ca*r” matches car, caaaaaar, and cr.
 Parentheses (()) used to group the set of regular expression conditions. Using groups is especially
useful for delimiting the argument(s) to an alternation operator ( | ) or a repetition operator ( * , +
, ? , { } ).
 A vertical line (|) instructs QuickTest to match one of a choice of expressions. For example: “foo|
bar” match either foo or bar.

84 Confidential
Regular Expression Examples

Regular Expression for Time Regular Expression for Date

Date Format: MM/DD/YYYY


Max Time: 23:59:59
Min  Time: 00:00:00 Min Day – 01 ; Max Day – 31
Min Month – 01 ; Max Month – 12
Hours: ([0-1][0-9]|2[0-3]) MM: (0[1-9]|1[0-2])

Mins: ([0-5][0-9]) DD: (0[1-9]|1[0-9]|2[0-9]|3[0-1])

YYYY: ([0-9][0-9][0-9][1-9]|[1-9]000|[1-9][1-9]00|[1-9][1-9][1-9]0)
Secs: ([0-5][0-9])

Special Character Explanation

| -- OR
() -- Used to group multiple regular expressions
[-] -- To specify a range

85 Confidential
86 Confidential

You might also like