Vous êtes sur la page 1sur 71

Types of Automated Tools:

3types:

1) Functional Tool -> EX: Quick Test Professional


(QTP) -> Win Runner
2)Management Tool-> EX: Test Director
-.>Quality Center
3) Performance Tool-> EX: Load Runner

QTP:
Type of the Tool: Functional
Company: Mercury interactive incorporation (HP)
Developed by Mercury
Scripting Language: VB
Versions: 1st. VER. 5.5 released in 2002
Version: 2nd VER. 6.5, 7.6, 8.0,
Version 5th 8.2 released in 2005
Version 6th 9.0 released in 2006
Version 7th and 8th 9.1 and 9.2 released in 2007
Operation systems those are compatible with
QTP
Win 2000 server
Advanced 2000 server
Win 2000 Pro
Win 2003 Server
2003 advanced server
VER 9.2 is compatible with XP Pro.

QTP is not compatible with UNIX and Linux


platforms
-INTRODUCTION COMPLETE-

The Anatomy of the QTP

Add in Manager:
It is a feature provided by QTP which is used
for specifying the environments before you are
entering into the QTP so that, it makes the QTP
compatible with that environment. By default
QTP provides, ActiveX, VB, and Web
applications.
Apart from this, QTP is always compatible with
standard windows environment.

QTP screen is divided into 7parts

1)Test Pane
It is an area provided by QTP used for
viewing the test script. It also allows the
user to do any kind of modifications on the
test script. It represents the script in 2
views.

A. Expert View:
It represents the script using VB script
language

B. Keyword view:
It represents the script using GUI
(Graphical Users Interface) which is further
divided into 4 parts.
1) Item, 2) operation 3) value 4)
documentation

2) Active screen:
It is feature provided by QTP which shows
the application state for each and every
script statement in terms of screen shots
which is used for the following. 1) To
understand the script easily 2) to enhance
the script easily

3) Data Table:
It is also called ‘Formula-One-Sheet’ which is
developed by the third party and integrated
by the QTP. It is used for the following:
1) Used for holding the test data
2) It has a capacity of importing the test
data from different data sources like excel
sheet, flat files and database.
3) It isolates the test script from the data
source.
4) It provides an API (Application program
interface) to interact with it directly
5) QTP maintains two copies of data tables
1) Design time data table 2) Run time data
table.
(Compares both tables to determine if the
test result is pass or fail)

4) Debug Viewer Pane:


It is used for viewing, modifying or setting
the current values of variables during the
execution break. Using the 3 tabs by names,
‘Watch expressions’, ‘Variables’ and
‘command’

5)Information View:
It is in the form of GUI and contains 4 tabs
Details: Describes of the each and every line
of ‘test pane’ area
Item, Action, Line
6)Missing Resources pane: Click on View in
the Information View and select Missing
Resources.
It is also in the form of GUI. It contains 2 tabs.
Item and Details.
Item contains missing item in the script.
Details describe the properties of that item.
7)Tool Options:
All the available options are tool options.
View-> Information view:
What ever is given in the script area is given
here. (9.2)
Recording and running feature in ‘QTP’

Record and run settings is the feature


provided by QTP which has to be
compulsorily used by a test engineer at least
for every new test before recording and
running in order to make the QTP aware
about on which application is going to
perform operations like record and run
session. For doing the same QTP provided 2
options.

1) Record and run on any open windows based


application

2) Record and run test on these applications


(opened on session starts)

Navigation for recording and testing:


Activate the menu item ‘test’ ‘Automation’
Select the option ‘record’
Select one of the following options
1) ‘record and run test on any open windows

based application’
2) ‘record and run test on these

applications’ ( opened on sessions start)

9.2 Record and run has more options


under ‘record and run settings’:
Application opened by Quick Test
Applications opened via desk top
Applications specified below (browse the
desired location)
If at all the ‘second option’ (3rd option in 9.2
under second option) is selected, click on the
‘add button’, click on ‘browse’ and browse the
desired application and select the application
and click on open. Click on OK, Click on apply
and click OK.
If you want to work with a specified
application then select the 2nd option in the
record and run settings.
If you want QTP to record only the
specified application then select the first
and third options.

Operational overview of ‘Recording’


feature in QTP:

While recording QTP will do the


following:
1) all the user actions are converted
into script statements
2) The corresponding object
information is stored in object
repository
And
Operational overview of ‘Running’
feature in QTP:
While running QTP will do the following:
1) first of all QTP will try to understand
the script statement i.e. what action
to be performed
2) Once it realizes what action to be
performed on an object, it needs to
identify the object.
3) For identifying the object it needs
some information. For that
information it will go to object
repository and search for the
information.
4) Once it identifies the information,
using that information it tries to
identify the object.
5) Once the object is identified, it
performs the action on it.
Types of Recording Modes:

• Normal or Context Sensitive or


Standard Recording mode
• Analog Recording mode
• Low Level Recording mode

1) Normal or Context sensitive or standard


recording mode:

It is used for recording the actions


that are performed on the standard
GUI objects

2) Analog recording mode:


When ever the context sensitive
recording fails, or whenever the user
wants to perform continuous recording
then there is a special recording mode
provided QTP is known as Analog
recording mode.

NAVIGATION for Analog recording


mode:
 Keep the tool under the normal
recording mode
 Activate the menu item

Automation,
 select the option Analog
Recording,
 Select one of the following options:

a) Record relative to the screen


b) Record relative to the
following window.
If the second option is selected specify
the window title of the application using
the hand icon and click on start Analog
recording.

3) Low level recording mode:


When ever there is an unsupported
environment by the QTP, but still the
user wants to record at least minimum
number of operations on the application
then the special recording mode
provided by QTP is known as low level
recording.

Note: If the user wants to be under


analog or low level recording mode,
first of all he should be under Normal
recording mode.
***********************************
*************
OBJECT REPOSITORY:
It is a storage place where one can store
the object’s information and also acts as
interface between the test script and the
AUT or ‘Application Under Test’ in order
to identify during execution.

.mtr (module test repository) is the


extension for saving the per action
repository files.
.tsr (test shared repository) is the
extension for saving the Shared
Repository files

‘TWO’ Types of Object Repositories:

a. Per Action Repository:


Per each and every action in a test QTP
will separately create a repository and
maintains that repository.

b. Shared Repository:
It is a common place where one can
store the objects information and can
be associated to multiple tests
Advantage: easy to maintain.
Disadvantage: Comparatively takes
more time during execution

NAVIGATION FOR CREATING A


“SHARED REPOSITORY”:
1) Open the application
2) Activate the menu item’ resources’

3) Select the option ‘Object repository’

4) Click on ‘Add objects local’ button

5) Click on the ‘title bar of the

application you require to share info


about’
6) Click on ‘OK’
7) Select the ‘third option’(select all

objects)
8) Click on ‘OK’

9) Click on ‘Export button’

10) Browse the ‘desired location’

11) Specify the ‘desired file name with .tsr

extension’ or test shared repository


12) Click on ‘Save’

Navigation for “Associating the shared


the Repository:”
Navigation:
Go to Resources and Associate
Repository
Click on + sign
Select the desired .tsr file

Click on Add ‘>’


Click on Repository View to confirm
Operations on Object Repository:
One can perform the following operations on
the Object Repository:

a) Adding the Objects


Navigation:
Open the application,
Resources -> object repository->Object
Click on ‘add object button locally’
->click on the ‘title bar’ of the desired
application
->click ‘OK’
->select one of the following options:
Click on OK

b)Navigation for deleting the objects:


Select the desired object in the Object
hierarchy right click on that select option
delete, and confirm by clicking on yes.

c) Navigation for renaming:


Follow the above instead of delete select
rename and rename

d)Navigation for updating the list of


properties:
Select the object in the object hierarchy,
click on add/remove button,
Select the desired properties to be added
or deselect to remove.
Click on OK

For 9.2 ‘High light’ button is in View -> high


light the abject
‘Locate Object’ is useful for finding out the
specified object in the Repository.
‘Export button’ is existing in the file
If you want to change the properties
value, click on constant value button and
specify the desired value, click on OK
Merging Of the Repositories:
Resources->object repository manager-
>tools->Object repository merge to-
>browse the primary file->browse the
secondary file you want to merge->click
OK
To save them click on ‘Save’ and specify
the file name you want it to save as.

OBJECT IDENTIFICATION:

It is based on the following properties:

1)Mandatory Properties:
2) Assistive Properties:
3) Base Filter Properties:
4) Optional Filter Properties:
5) Ordinal Identifier:

QTP learns the information in the following way:


At first QTP learns the complete list:
1) Mandatory properties: Analyzes it self
whether these properties are sufficient for
identifying the object uniquely. If it feels
insufficient then it will learn the first

2) Assistive property: If it still feels


insufficient, then it will learn the next assistive
property. This process continues till the last
available assistive property or till the QTP is
satisfied. If it still feels insufficient then it will
learn the Ordinal Identifier.

Note: If smart identification mechanism is


invoked, then along with the mandatory
properties, QTP learn the 3) base filter and 4)
optional filter properties and stores them
separately. The remaining process is same as
above.

Note:
The Mandatory properties, Assistive properties
and the ordinal identifier that was learnt are
stored in the object repository.
5) ORDINAL IDENTIFIER:

There are 3 types of Ordinal Identifiers.


a.Location:
Based on the sequence in which the objects
are located in
AUT (Application under Test) QTP will
generate the numbers starting from ‘0’ zero
on wards.
b. Index:

Based on the sequence of the programs, QTP


will generate the numbers
Starting from 0 on wards
c.Creation Time:
Based on the loading time of the WEB page
QTP will generate a sequence of numbers
starting from 0 (Zero) on wards.

Navigation:
Tools->object Identification->select the
desired environment->select the desired
object class to be configured EX: VB buttons
etc.

Click on Add/remove button->select the


desired properties to be added
For mandatory and assistive properties

Select the check box ‘enable smart


identification’ click on configure button
Specify the base filter and optional filter
properties by clicking on the corresponding
add/remove button. Click OK
Select the desired ordinal identifier. Click ok
Note: this configuration will be in effect
from the next new file onwards.

OBJECT SPY:

It is a handy feature provided by QTP, which


shows the complete information like list of
properties, list of methods, syntax for
methods and description of methods for both
‘Test objects’ as well as ‘Runtime objects’.

Runtime Objects:
The original objects present in the application
are known as Runtime objects
Test Objects:
Test objects are the references for the runtime
objects created by QTP, used by QTP during
execution in order to identify the runtime
objects.

QTP LIFE CYCLE:


1) Test Planning
2) Generating the basic Test
3) Enhancing the test
4) Debugging the test
5) Executing the test
6) Result analysis

1) Test planning:
In the test planning phase, the test lead will
identify the areas to be automated and the
automation test engineer will do the
following:
A. Understanding the requirements
B. Analyzing the flows
C. Pre configuration settings to the tool in
order to make the tool ready for further
operations

2) Generating the basic test:


In the phase automation test engineer will
generates the basic test for both positive
and negative flows

3)Enhancing the test:


1) CHECK POINTS:
2)Synchronizing the test:
3) Parameterize the test or data driven
testing (DDT):
4) Inserting the output values:
5) Measuring transactions:
6) Inserting the programmatic statements
7) Inserting the script statements manually

A. CHECK POINTS:

It is also called as validation point or


testpoint which checks the application state
or data state during the execution at any
point of time.

Operational over view of Check Point:


It is divided into 2 phases.
Pre execution phase
a) Captures the expected value
b) Generates the test script statement

While execution phase


a) Captures the actual value
b) Compares the actual value with the
expected value
c) Displays the result

Types of Check Points:


I. Standard
II. Bitmap
III. Text
IV. Text Area
V. Database
VI. XML
VII. Accessibility
VIII. Page
IX. Table
X. Image
Checkpoint Description Example of Use
Type

Standard Checks values of an object's Check that a radio button is selected.


Checkpoint properties.

Image Checks the property values of an Check that the image source file is correct.
Checkpoint image.

Table Checks information in a table. Check that the value in a table cell is correct.
Checkpoint

Page Checkpoint Checks the characteristics of a Web Check how long a Web page takes to load or if a Web
page. page contains broken links.

Text Checkpoint Checks that a text string is displayed Check whether the expected text string is displayed in
in the appropriate place in a Web the expected location in a test object.
page or application.

Text Area Checks that a text string is displayed Check that an area of a dialog box includes text that
Checkpoint within a defined area in a Windows- was entered in another part of the application.
based application.

Bitmap Checks an area of a Web page or Check that a Web page (or any portion of it) is
Checkpoint application after capturing it as a displayed as expected.
bitmap.

Database Checks the contents of databases Check that the value in a database query is correct.
Checkpoint accessed by an application or Web
site.

Accessibility Identifies areas of a Web site to Check if the images on a Web page include ALT
Checkpoint check for Section 508 compliancy. properties, required by the W3C Web Content
Accessibility Guidelines.

XML Checkpoint Checks the data content of XML Check the content of an element to make sure that its
documents. tags, attributes, and values have not changed.
Note: XML file checkpoints are used to check a
specified XML file; XML application checkpoints are
used to check an XML document within a Web page.

1)Standard check point:


It is used for checking the standard GUI
object’s property’s value.
Navigation:
Open the ‘desired application’ that you
need to test
Keep the tool under ‘recording mode’
Activate the menu item insert
Select the option check point
Select Standard Check point
Take the hand icon
Click on the desired object or application
that you want to test
Click OK
Select the desired properties to be
checked
Click OK
Stop recording
Click on RUN and analyze the results

2) Bit map check point:


It is used for checking the bit maps or
comparing the bitmaps
Navigation: Same as above but can
select the desired area of the bitmap

3) Text check point:


Navigation:
4) Text area check point:

5) Database check point:

‘Database Check Point’ is used for checking


the contents of the data table in a
Database.

Navigation ‘Database Check Point’:


Insert -> check point-> database
checkpoint
Select the ‘specify SQL statement
manually’
Click next
Create->new->
Select the desired driver
Next
Specify the data source name
Next
Finish
Select
Select the desired drive
Select the desired database
Ok
Ok
Ok
Specify the SQL statement manually
> Select *from <
Finish
Select the desired columns to be checked
Select one of the options ‘before current
step’ or ‘after current step’
Click OK
Click RUN and analyze results

6) XML check point:


It is used for checking the contents of an
xml file

XML: Extensible mark up language is a


universally understandable language which
is mainly used for data transmission.
How to create an XML files (text file)
Navigation for ‘XML Check Point’:
7)Accessibility check point (web check points)
It is used for checking whether the page
has been developed according to the ‘www’
constraints or standards are not

Navigation:
Keep the cursor on the desired statement;
select the ‘active screen’
Go to Active Screen; right click in the
Active Screen, select accessibility check
point, select after current step. Click on
OK
Run and analyze results

8)Page check point (Hidden check points) (web


check points)
It is used for the checking the properties
of the web page like number of images,
number of links and load time etc.

Navigation is same as above except select


‘standard check point’ instead of
‘Accessibility check point’
9)Table check point (Hidden check points) (web
check points)
It is used for checking the contents of the
web tables.
Navigation is same as above but select
‘Page Check point’

10) Image check point (Hidden check points)


(web check points)
It is used for checking the properties of
an Image.
Navigation same as above except select
‘Image check point’

Check point is used to measure the object


property’s value

B. Synchronizing the test:


It is a process of matching the speeds of
both the tool and the application involved in
testing in order to keep them in synch with
each other to obtain proper testing results.
The main concept of synchronization is
making the tool to wait.

It can be done in the following ways:


1) Inserting the synchronization point:

Navigation:
Keep the cursor on the desired location.
Keep the tool under the ‘record mode’
Activate the menu item ‘insert’
Select the option ‘synchronization point’
Specify the property ‘(enabled)’
Specify the property value ‘(True)’
Specify the extra time in ‘mille seconds’
Click ‘OK’
‘Stop recording’.
Click ‘run’ and analyze the results.
In order to avoid the above navigation,
insert the following statement in the
script where it is needed: (Script
syntax)
Object hierarchy.waitproperty
“property name” property Value, extra
time in mille seconds.
EX: Window (“Flight Reservation”) Wait
Property “Enabled”, true, 15000 ms

2) Inserting a wait statement:


It is used for making the tool to wait till
the specified time is elapsed.
Navigation: Syntax
Wait (time in seconds)
EX: wait (10)

3)increasing the default time:


Navigation:
Activate the menu item ‘File’
Select the option ‘settings’
Select the ‘run’ tab
Specify the extra time in the object
synchronization field in seconds.
Click on ‘apply’ and click on ‘OK’
C. Measuring transactions:
It is a concept provided by QTP to calculate the time
taken by an application to perform a specific task.
In order to do the same, QTP has provided 2 options.
Start transaction, End Transaction.
Navigation:
Keep the cursor on the desired location; activate the
menu item’ insert’.
Select the option ‘starts transaction’ Specify the
transaction name.
Select one of the options before current step or
after current step.
OK.
Follow the same transaction for End Transaction.
In order to avoid the above navigation one can insert
the following statements into the script:

Services.starttransaction “transaction name”

Services.Endtransaction ‘transaction name”


D. Parameterize the test or data driven
testing (DDT):
It is a concept provided by QTP to
implement retesting.
Navigation for DDT:
1)collect the test data in the Data Table
2) generate the basic test
3) Parameterize the test
4) Execute the test
5) Analyze the results
Parameterization:
It is process of replacing the constant
values with the parameters or variables in
order to increase the scope of the test.

Parameterization can be done in the


following ways:

A) Data Drive Wizard Parameterization


B) Keyword View Parameterization
C) Manual Parameterization

Navigation:
1)Through Data Drive Wizard:
Tools -> Data driver->
Select the ‘constant value to be
parameterized’
Click on ‘Parameterize button’
Select step by step parameterization,
Next->
Click on ‘Parameter’ options button
Specify the desired column name
Click on OK
Click on Finish and click OK

Navigation:
2) Through Keyword View:

Select Keyword ‘View’


Select the ‘constant value to be
parameterized’
Click on ‘configure’ the value button
Select the option ‘parameter’
Sp the ‘desired column name’ or specify the
name
Click on OK
3) Manual Parameterization:
In order to avoid the above navigation, one
can manually insert the following
statements:
Syntax:
Vbwindow (“form1”).vbedit (“val1”).set
datatable (“V1”, 1)
Vbwindow (“form1”).vbedit (“val2”).set
datatable (“V2”, 1)
Vbwindow (“form1”).vbButton (“ADD”).Click
Navigation for importing the data from
Data base/flat files/xls:
Right click in the data table
Select file
Select import from file
OK
Browse the location of the desired file
Select the desired file
Click on OPEN
Note:
In order to have the ‘Test Results’ in the
‘Run Time DATA TABLE’ we need to set the
“Check Point”
Navigation to Parameterize the Check
Point:
Right click on the check point statement,
Select check point properties
Select the desired properties
parameterized
Select the parameter option
Click on the parameter options button
Select the desired column name
OK and OK

E. Inserting the output values:


It is a feature provided by QTP to capture
a value from an application or Database or
XML file and stores it under a specified
column in the runtime DATA TABLE during
execution.

F. Inserting the programmatic statements:


Test Pane may contain 5 types of Programmatic
statements:
2) Normal steps or Object calls
3) Conditional statements
4) Looping statements
5) Comments(by using the word “REM” before the

statement)
6) Utility statements
7) Reporter Statements:
Reporter utility object is used for reporting a ‘User
Defined Message’
UDM to the results window
Syntax for the Reporter Statement’
Reporter.reportevent status,”myreport”,”user
defined message”.
Reporter.reportevent micdon,”Myreport”,”I am the
Best”

Adding comments:
Comments can be inserted into the Test Pane area
just by preceding with an ‘apostrophe OR USE A
WORD REM FOR ADDING COMMENTS

G. Inserting the script statements manually:


EX: manual parameterization.

4) Debugging the test:


It is a process of executing the program with some
temporary breaks in order to identify the errors to do the
same QTP has provided 3 step commands and a Break Point.
a) Step into: it is used for executing a single step. If that
step is a ‘Function call’ or ‘Action Call’ then it will enter
into a Function/Action.
b)Step out: It is used for executing all the programmatic
statements from the pointer (arrow) and steps out of
the Function/Action.
c) Step over: It is used for executing the complete block
of statements in a Function/Action if that step is a
Function Call /Action Call. Otherwise, it will execute
single step only.
d)Break Point: It is a feature provided by QTP that is
used for breaking the execution temporarily.

5) Executing the test:

A Test Engineer will execute the script in this Phase.

6) Result analysis:

A Test Engineer will analyze the results in this phase.

Recovery Scenario:

It is defined as a problematic situation wherein QTP needs


to recover by itself.
To do the same a Test Engineer would have already defined
a solution and associated it to the test before the
execution starts.

During the execution if QTP faces a problematic situation


then, if the solution is available it will use the solution and
over comes that situation.

There are 4 types of Trigger Events to over come


different kind of situations.
a) Popup Window:

This is used for defining a solution to over come a


problematic situation related to ‘POP UP WINDOW’.
Navigation: Activate ‘Resources’
Recovery scenario manager
New scenario
Next
Select ‘trigger event’ pop up window
Next
Take the hand icon and click on the desired popup window
Next
Next
Select recovery operation as ‘Keyboard or Mouse’
operation
Next
Select Click button with Label option
Take the hand icon and click on the desired button in the
popup window to be clicked
Next
De-select the check box ‘Add another recovery
operation’
Next
Select Post-Recovery-Test-Run options as
Repeat current step and continue
Next
Specify a scenario name
Next
Select the check box ‘Add scenario to the current test’
Finish
Click on SAVE
Specify a file name with .QRS extension (Quick Recovery
Scenario)
Close. Click on RUN and analyze the results

b) OBJECT STATE:
This trigger event is used for defining a solution to over
come the problematic situation faced by the QTP during
execution that is related to Object State.
Navigation:
Resources-> Recovery Scenario manager-> new scenario-
>Next->Object State->Next->take the hand ICON and
click the pop up window ->OK
->Next->if you want to add the properties, click on
ADD/Remove button, and select the desired properties
to be added
Next
Next
Function Call
Next
Click on browse, select the desired .vbs file
Open -> specify a function name
Then insert the necessary statement in between
‘function’ and ‘end function’
Next
Deselect the check box ‘Add another recovery operation’
Next
Select ‘repeat current step and continue’
Next ‘specify a scenario name
Next select the check box ‘add scenario to current test’
Finish
Click on ‘save’ specify the desired file name with .qrs
extension
Click on ‘save’ and click on close and then click run.

c) TEST RUN ERROR:


It is used for defining a solution to over come a
problematic situation like a step in your test does not run
successfully during execution.
Navigation: Tools->recovery scenario manager->new
scenario
->Next->Test run error-> select the error type as ‘any
error’
Next->Next->function call->browse the desired VBS file
(library)
Next->deselect the check box ‘Add another recovery
operation’
Next->Proceed to next step->next->scenario name->next
Select the check box ‘Add the scenario to the current
test’
Finish. Click on Save. Specify a file name and click on Save
and close
Click on run and analyze the results.

d)APPLICATION CRASH:
It is used for defining a solution to over come a
problematic situation like the application fails during the
execution.
REGULAR EXPRESSIONS:

When ever the QTP is unable to identify the object due


to its regular changes in the object’s property values
to over come from that problematic situation the
solution provided is regular expression.

Whenever the object’s properties’ value is being


regularly changed dynamically then that constant
value present in the object repository has to be
replaced with a Regular Expression.
Navigation:
Open the ‘object repository’
Select the desired ‘test object’
Select the desired ‘property’ whose value to be
replaced with a regular expression, click on the
‘constant value’ options button,
Replace the constant value with desired ‘regular
expression.’
Select the check box ‘regular expression’
Click on ‘NO’
Click OK
Change the same thing in the repository also.
Click OK.

FRAME WORKS
It is a set of generic guidelines designed by the
experts to accomplish a task in an effective, efficient
and in an optimized way.
There are 4 types of Frame Work:
Linear
Modular
Keyword Driven
Hybrid or Sandwich

1) Linear Frame Work:


a) Generating the basic script
b) Enhancing the script
c) Debugging the Script
d) Executing the Script
e) Analyzing the Results

2) Modular Framework:
An action is a combination of one or more statements
to perform a specific task that would returns a
resulted action.
Create the components or the Actions

Make them as reusable Actions


Prepare the drivers based on the end to end
scenarios
Execute the drivers
Analyze the results
Reporting

Navigation for splitting an action into 2


actions:
Save the ‘Action’
Keep the cursor on the first line of the
second part
Activate the menu item ‘Edit’
Select the option ‘Action’ and ‘Split Action’
Select one of the following:
Independent of each other
Nested
Specify the desired name of the Action to
save
Click OK

Navigation to make the Actions into


‘Reusable’ actions
Activate the menu item ‘Edit’
Select the option ‘Action’ Select ‘Action
Properties’
Select the check box ‘reusable action’ and
click ok.

Navigation for creating a new Action:


Activate the menu item ‘Insert’
Select the option ‘Call to new Action’
Specify the action name
Select one of the following
At the end of the test
After the current Step
Click ‘OK’
Navigation for renaming an Action:
Activate the menu item ‘Edit’
Select the option ‘Action’ Select ‘Action
Properties’
Rename to the desired name and click ok.

Navigation for calling an Existing action:


Activate the menu item ‘Insert’
Select ‘Call to Existing’ action
Browsed the desired location
Select the desired action from the drop
down
Select one of the following
At the end of the test
After the current Step
Click ‘OK’

Navigation for “Calling Copy of Action”


(used for editing reusable Actions)
Activate the menu item ‘Insert’
Select ‘Call to Copy of action’
Browsed the desired location
Select the desired action from the drop
down
Select one of the following
At the end of the test
After the current Step
Click ‘OK’
3) Keyword Driven Frame Work:

Create the SW structure as followed:


 Create a folder in a desired drive with the
projectName_Auto
 Open the folder and create 7 more sub folders
with the names
• Library
• Repository
• Test
• Test Data
• Environment
• Recovery
• Log
 Create the desired library files (.VBS or Visual
basic script), Desired Repositories (.TSR or Test
Shared Repository),Desired Recovery files (.QRS
or Quick Recovery Scenario), Desired Test Data,
Desired Test and save them in the corresponding
sub folders
 Open the main TEST
 Associate the required resources like libraries,
repositories, Recovery, Test and Test Data
4) Hybrid Frame Work:
The combination of Linear, Modular and Keyword
driven is known as Hybrid Frame Work.
-End of Frame works-

REAL TIME ORIENTATION METHODS

Simple Methods:
Click’ method:
a) ‘
This is used for Clicking on a specified
object
Syntax: Object hierarchy.click[x, y[button]]
b) ‘DBL Click’ method:
This is used for double clicking on a
specified Object
Syntax:
objectHierarchy.dblclick[x,y[button]]
c) Set method:
This is used for setting a value into ‘Edit
box’, Selecting or deselecting a ‘check box’,
selecting an ‘option button’ (radio button)
Syntax for ‘Edit box’:
ObjectHierarchy.set”value”
Syntax for ‘Check Box’:
ObjectHierarchy.set”on/off”
Syntax for ‘Option button’ (Radio button)
ObjectHierarchy.set

CASE STUDY 1:
Develop a script for entering the EName,
EAge, ESal, EDesignation and clicking on
Submit button.
Script:
Vbwindow(“EMP”).vbedit(“EName”).set”Jaya

Vbwindow(“EMP”).vbedit(“EAge”).set”49”
Vbwindow(“EMP”).vbedit(“ESal”).set”$100.0
00”
Vbwindow(“EMP”).vbedit(“EDesignation”).set
”QAManager”
Vbwindow(“EMP”).vbbutton(“Submit”).click

CASE STUDY 2:
Develop a script for selecting the check
box for ‘testing tools’, ‘live projects’, ‘sql’
server in ‘Orbit’ form and clicking on
‘submit’ button.
Vbwindow(“ORBIT”).vbCheckbox(“TestingT
ools”).set”on”
Vbwindow(“ORBIT”).vbCheckbox(“LiveProje
ct”).set”on”
Vbwindow(“ORBIT”).vbCheckbox(“SQL”).set
”on”
Vbwindow(“ORBIT”).vbCheckbox(“MultiMed
ia”).set”off”

“If they have selected any other than


specified requirements then you have to
make sure that it is not selected.( Above
EX: multimedia)”
Vbwindow(“ORBIT”).vbButton(“Submit”).clic
k

CASE STUDY 3:
Develop a script for entering a ‘Cast’, ‘Age’,
selecting the ‘gender’ and clicking on ‘search
button’ in form 1.
Vbwindow(“From1”).vbEditbox(“Cast”).set
“A”
Vbwindow(“From1”).vbEditbox(“AGE”).set
“50”
Vbwindow(“From1”).vbRadioButton(“Male”).s
et
Vbwindow(“From1”).vbButton(“Search”).Click

d) Select Method:
This is used for selecting an item in a ‘combo
box’ or ‘list box’.
Syntax: objectHierarchy.select”item name”
CASE STUDY 1:
Develop a script for entering a ‘name’, ‘age’,
selecting ‘from’, ‘to’, and setting a ‘train number’
and selecting the ‘gender’ and ‘clicking on
Submit button’ in ‘Res’ Form
Vbwindow(“Res”).vbEdit(“Name”).set ”Jaya”
Vbwindow(“Res”).vbEdit(“Age”).set ”49”
Vbwindow(“Res”).vbComboBox(“To”).select
“Hyderabad”
Vbwindow(“Res”).vbComboBox(“From”).select
”New Delhi”
Vbwindow(“Res”).vbEdit(“Train #”).set ”9”
Vbwindow(“Res”).vbRadioButton(“Female”).set
Vbwindow(“Res”).vbButton(“Submit”).click

e) Activate Method:
This is used for activating a
window/application/browser
Syntax: objectHierarchy.activate
Vbwindow(“form1”).activate

f) Close Method:
This is used for closing a
window/application/browser
Syntax: ObjectHierarchy.close
Vbwindow(“form1”).close

g) Set secure Method:


This is used for setting an encrypted data into
the Edit Box.
Syntax: ObjectHierarchy.setsecure”encrypted
string”
Navigation for generating encrypted string
Start->Programs->QTP->Tools->password
encoder
Dialogue (“login”).winEdit(“password”).setsecure
”encryptedString”
h) Type Method:
It is used for performing any kind of keyboard
related operations.
Syntax: objectHierarchy.type keyvalue
Dialogue (“login”).winEdit(“passWord”).type
micTab
(Make sure that there is space between ‘type’
and ‘keyvalue’)

GET ‘RO’ PROPERTY:


It is used for getting a runtime object’s property’s
value during the execution.
Syntax:
Variable = Object Hierarchy.getROproperty
(“Property name”)
CASE STUDY 1:
Develop a script to select ‘ProductID’ and to enter
the quantity and to click on the ‘CAL’ button to check
the amount manually in form ‘PRODUCT’.
Script:
Vbwindow(“PRODUCT”).vbComboBox(“PID”).select
“0077”
VbWindow("PRODUCT").VBEdit("Quantity").set "9"
R=vbWindow("product").VBEdit("PRate").getROproper
ty ("Text")
Q=VbWindow("product").VBEdit("Quantity").getROpr
operty ("Text")

'Expected Value (EV), Actual Value (AV) comments.

ev = r*q
VbWindow("Product").vbButton("CAL").click
AV =
VBWindow("product").VBEdit("Amount").getROproper
ty("Text")
if (EV = AV) then
reporter.reportevent micpass,"MyReport","Pass"
Else
reporter.reportevent micFail,"MyReport","Fail"
End if

GET ‘TO’ PROPERTY:


It is used for getting the text object’s property’s
value during the execution.
Syntax:
Variable = Object Hierarchy.getTOproperty
(“Property name”)
SET ‘TO’PROPERTY:
It is used for setting the text object’s property’s value
temporarily during the execution.
Syntax:
Object Hierarchy.setTOproperty
“propertyName”,”propertyValue”
(Space must be there after ‘setTOproperty and
propertyname.)

COMMONLY USED VB SCRIPT FUNCTIONS:


CSTR:
This is used to converting a value into a string

CBOOL:
This is used to converting a value into a Boolean value

CINT:
This is used to converting a value into an integer value

CDBL:
This is used to converting a value into a double value
or float

LTRIM:
This is used for trimming the left side spaces
RTRIM:
This is used for trimming the right side spaces

TRIM:
This is used for trim both side spaces

MID:
This is used for returning a sub-string

LEFT:
This is used for returning a LEFT sub-string
Dim a, b
a = “I am Great in Testing”
b = Left (a, 8)
msgbox(b)

RIGHT:
This is used for returning a RIGHT sub-string
Dim a, b
a = “I am Great in Testing”
b = Right (a, 8)
msgbox(b)
ROUND:
This is used for rounding a decimal value to nearest
integer

CEALL:
It is used for ceiling the value (Highest nearest integer
is Ceiling)

FLOOR:
It is used for flooring the value. (Lowest nearest
integer)

DATA TABLE METHODS

Add Sheet Method:


This is used for adding a specified sheet to a
runtime Data Table.
Syntax:
DataTable.AddSheet”SheetName”

Delete Sheet Method:


This is used for deleting a ‘user defined’ sheet from
a ‘runtime Data Table’
DataTable.deleteSheet”SheetName”
Import Method:
This is used for importing all the sheets in an ‘Excel
file’ to a runtime Data table
Syntax:
Datatable.import”FullPath with a file name .xls
extension”)

Import Sheet:
It is used for importing a specified sheet from an
‘Excel’ file to a specified location in the runtime Data
Table.
Syntax:
Datatable.importsheet”Full Path”, source Sheet ID,
Destination Sheet ID

Export Method:
It is used for exporting all the sheets in the
runtime Data table to a specified location in the
hard Disk
Syntax:
Datatable.export”Path of the location with the file
name .xls extension”

Export Sheet Method:


It is used for exporting a specified sheet from the
runtime Data Table to specified location in the hard
disk
Syntax:
Datatable.exportsheet”Path of the location with
the file name .xls extension”, sheetID

Set current Row Method:


This is used for setting the focus of QTP to
specified ROW
Syntax:
Datatable.setcurrentROW(ROW number)

Set Next Row Method:


It is used for setting the QTP’s focus to the next
ROW of the currently focused ROW
Syntax:
Datatable.setNextROW

Set Previous Row Method:


Syntax:
Datatable.setPreviousRow

Get Sheet Method:


It is used for making the QTP focus on a specified
sheet
Syntax:
Datatable.getSheet(sheetId)

Get Row count method:


It is used for getting the ROW count of a sheet by
default it will get the ROW COUNT of the Global
sheet. If one needs to get the ROW COUNT of a
specified sheet, first we need to focus the sheet,
then get the ROW COUNT.

Syntax for getting the ROW COUNT of the Global


Sheet:
Variable=datatable.getRowCount

Syntax for specified sheet


Variable = datatable.getsheet(sheet ID.getRowCount)

DESCRIPTIVE PROGRAMMING
If the description is described in the program itself then it
is known as DESCRIPTIVE Programming.

Script:
Dialog("Text:=Login").WinEdit("Attached Text:=Agent
Name:").Set "Jaya"
Dialog("Text:=Login").WinEdit("Attached
Text:=Password:").SetSecure
"47257f2ff7200f866a1a9285db8ad6dac9bd7932"
Dialog("Text:=Login").WinButton("Text:=OK").Click

ENVIRONMENT VARIABLES
It is concept provided by QTP to declare and
define Variable once and use them in the
multiple tests in the same environment.
There are two types of Environment Variables.
A) Built in Variables, B) User defined Variables.
A)Built in Variables:
These are the variables already declared
and defined by the QTP and associate to
each and every new test so that one can
use them directly in the script using
following Syntax:
Environment.value(“VariableName”)
B) User Defined Variable:
Apart from built in variables, if the user
wants to declare and define a variable
which can be used commonly across many
tests then he can declare them as ‘User
defined Variables”. If the Variables are
declared in the TEST then it is known as
‘Internal Variables’. If the Variables are
imported from an External file, then
those Variables are called as ‘External
Variables’.

Navigation for Declaring and Defining


Variables:
Activate the menu item File
Select the option settings
Select Environment Tab
Select the Variable type as ‘user defined’
Click on plus button
Define the variable and the value
If needs to exports the variable then
click the export button
Specify the file name with .xml
extension. (XML files)
If order to avoid the above navigation
one can directly prepare the following
XML file in Note pad.

Format for creating External


Environment Variables in XML:
<Environment>
<Variable>
<Name>SAI</Name>
<Value>9</Value>
</Variable>
<Variable>
<Name> X </Name>
<Value>7</Value>
</Variable>
</Environment>

Navigation for Associating the External


Variables:
Activate the menu item File
Select the option settings
Select Environment Tab
Select the Variable type as ‘user defined’
Select the check box ‘load variables and
values from external file’
Click on browse; Select the desired ‘XML’
file
Click on Open, click on Apply and click OK

Syntax: EX:
VbWindow("Form1").VbEdit("val1").Set
environment.Value("SAI")
VbWindow("Form1").VbEdit("val2").Set
environment.Value("X")
VbWindow("Form1").VbButton("ADD").Cli
ck
VbWindow("Form1").VbButton("SUB").Clic
k
VbWindow("Form1").VbButton("MUL").Cli
ck
VbWindow("Form1").VbButton("DIV").Clic
k
INPUT/OUT PUT PARAMETERS

It is a concept provided by QTP in order


to serve the purpose of passing the
values into the action and to get some
values from the action. For doing
the same QTP has provided input/output
parameters.
Note: These parameters have to be
declared at the action which is about to
be called.
Navigation for declaring Input/output
parameters:
Edit->Action->Action Properties-
>Parameters tab->click on + and declare
the input Parameter. Select the
parameter type and specify the value.
Click on the + button on the output
parameters, specify the Output
parameter name and select the
parameter type and click on OK.

Syntax:
bWindow("Form1").VbEdit("val1").Set
parameter("A")
VbWindow("Form1").VbEdit("val2").Set
parameter("B")
VbWindow("Form1").VbButton("ADD").Cli
ck
parameter
("D")=Vbwindow("Form1").VbEdit("Res").G
etROProperty("Text")

BATCH TESTING
Test Batch Runner:

It is awesome concept provided by QTP


to execute a group of tests at a time. For
doing the same QTP has provided a
separate tool known as TEST BATCH
RUNNER.

Note: in QTP you have to do the following


modifications
Tools->Options->Run Tab->select the
check box
”Allow Other Mercury products to run
test and components”
Navigation:
Start -> Programs->QTP->Tools->Test
Batch Runner
Click on Add and add the desired test,
Click on save. Specify a file name with
.mtb extension (mercury Test Batch)
When ever needed open the saved .mtb
file and run.

Database Connections

Dim con, rs
Set con=createobject(“adodb.connection”)
Set rs=createobject(“adodb.recordset”)
Con.provider=”Microsoft.jet.oledb.4.0”
Con.open=”D:\nagesh\database.mdb”(give the
path of the database)
Rs.open”select*from DATABASE TABLE
NAME”, con (give the name of the table)
Do while not rs.eof (end of file)
Vbwindow(“form1”).vbedit(“val1”).set
rs.fields(“v1”)
Vbwindow(“form1”).vbedit(“val2”).set
rs.fields(“v2”)
Vbwindow(“form1”).vbbutton(“add”).click
rs.movenext
Loop
-----------------------------------END of Automation----------------------------------

Vous aimerez peut-être aussi