Beruflich Dokumente
Kultur Dokumente
Qtp
INDEX: PAGE No:
INTRODUCTION 5
WAYS OF TESTING
MANUAL TESTING
AUTOMATION TESTING
DRAWBACKS OF MANUAL TESTING
DRAWBACKS OF AUTOMATION TESTING
INTRODUCTION TO AUTOMATION TESTING
NEED OF AUTOMATION TESTING
FRAMEWORK TO LEARN ANY AUTOMATED TOOL
TYPES OF AUTOMATED TOOL
HISTORY OF QTP
BASICS OF QTP 7
ANATOMY OF QTP
RECORD AND RUN SETTINGS
RECORDINGS
RECORDING MODES
CONTEXT SENSITIVE
ANALOG
LOW LEVEL
VB SCRIPT
OBJECT REPOSITORY
TYPES OF OBJECT REPOSITORIES
LOCAL
SHARED
OPERATIONS ON OBJECT REPOSITORY
OBJECT REPOSITORY MANAGER
OPERATIONAL OVERVIEW OF RECORDING AND RUNNING
OBJECT IDENTIFICATION
SMART IDENTIFICATION
OBJECT SPY
TYPES OF OBJECTS
RUN TIME OBJECTS
TEST OBJECTS
REPORTING MT-Notes
MANUAL DEFECT REPORTING
BUG TRACKING TOOL ORIENTED DEFECT REPORTING
INTEGRATION WITH QUALITY CENTER
ACTIONS 33
INTRODUCTION
TYPES OF ACTIONS
NORMAL ACTIONS
REUSABLE ACTIONS
EXTERNAL ACTIONS
CREATING NEW ACTIONS
SPLITTING ACTIONS
RENAMING ACTIONS
WORKING WITH DATA TABLE ACTION SHEETS
WORKING WITH INPUT AND OUTPUT PARAMETERS
FUNCTIONS 32
NEED OF FUNCTIONS
CREATING USER DEFINED FUNCTIONS
WORKING WITH UDF’S
LIBRARIES 36
INTRODUCTION
CREATING LIBRARY FILES
ASSOCIATING LIBRARY FILES
DESCRIPTIVE PROGRAMMING 60
INTRODUCTION
CREATING DESCRIPTIVE SCRIPTS
ADVANTAGES
REGULAR EXPRESSIONS 56
INTRODUCTION
ADVANTAGES OF REGULAR EXPRESSIONS
FRAMEWORK IMPLIMENTATION 32
LINEAR
MODULAR
KEYWORD DRIVEN
HYBRID
DATA DRIVEN
VB SCRIPT 38
VB SCRIPT LANGUAGE OVERVIEW
VARIABLES
CONSTRANTS
DATA TYPES
ARRAYS
STATEMENTS
CONDITIONAL STATEMENT
IF……..THEN
SELECT CASE
LOOPING STATEMENTS
FOR………..NEXT
DO…………WHILE
DO………….UNTIL
WHILE…...WEND
OTHER STATEMENTS
CALL
DIM
EXIT
WAIT
EXECUTE
OPTION EXPLICIT
SET
WITH
OPERATORS
ARTHEMATIC
COMPARISION
CONCATINATION
LOGICAL
PROCEDURES
SUB PROCEDURES
FUNCTION PROCEDURES
PRE DEFINED FUNCTIONS
DATA AND TIME
STRING
CONVERSION
TRIMMING
OTHER FUNCTIONS
PREPARED BY 62
PC SURENDRA REDDY
QTP
WAYS OF TESTING:
1.MANUAL TESTING
2.AUTOMATION TESTING
1. MANUAL TESTING: Manual Testing is a process, in which all the phases of STLC (Software Testing Life Cycle) like
Test planning, Test development, Test execution, Result analysis, Bug tracking and Reporting are accomplished
successfully and manually with Human efforts.
DRAWBACKS:
2. AUTOMATION TESTING: Automation Testing is a process, in which all the drawbacks of Manual Testing are
addressed properly and provides speed and accuracy to the existing testing process.
DRAWBACKS:
Note: Automation Testing is not a replacement for Manual Testing, it is just continuation for Manual Testing.
Note: Automation Testing is recommended to be implemented only after the application has come to a stable stage.
AUTOMATED TOOLS: Automated tool is defined as an assistant of test engineer, which works based on the
instructions and information given by us and finally shows the result.
Apart from these 2 tools the test engineer will use MANAGEMENT TOOL (QUALITY CENTER) for managing the
testing process.
Introduction of QTP:
Type of the Tool : Functional tool.
Company : Introduced by INTERACTIVE IN CORP. & taken over by HP in the year 2002.
Script language : VB Script (It can understand other scripting languages also).
Versions :
VERSION YEAR OF RELEASED
ASTRA 1998
5.0 2000
5.5 2001
6.0 2002
6.5 2003
8.0 2004
8.2 2005
9.0 2006 FEB
9.1 2007 JAN
9.2 2007 FEB
9.5 2008 JAN
ANATOMY OF QTP:
VB SCRIPT:
Syntax:
Complete HIERARCHY.OPERATION.”VALUE”
CLASS NAME(“OBJECT NAME”).-------------------.OERATION.”VALUE”
VbWindow(“emp”)VbEdit(“ename”).set”SURI”
VbWindow(“emp”)VbEdit(“eage”).set”26”
VbWindow(“emp”)VbEdit(“esal”).set”40,000”
VbWindow(“emp”)VbEdit(“edesig”).set”SE”
VbWindow(“emp”)VbButton(“submit”).CLICK
Browser(“ie”)Page(“yahoo”).WebEdit(“user name”).set”SURI”
Browser(“ie”)Page(“yahoo”).WebEdit(“password”).set”surendra”
Browser(“ie”)Page(“yahool”).Webbutton(“login”).CLICK
Browser(“ie”)Page(“emp”).WebEdit(“ename”).set”SURI”
Browser(“ie”)Page(“emp”).WebEdit(“eage”).set”26”
Browser(“ie”)Page(“emp”).WebEdit(“esal”).set”40,000”
Browser(“ie”)Page(“emp”).WebEdit(“edesig”).set”SE”
Browser(“ie”)Page(“emp”).WebButton(“submit”).CLICK
ADD INN MANAGER: Add inn manager is a feature provided by the QTP, which is used for making the QTP,
compatible with the desired environments.
Add inn manager will show the list of all available add inn’s, while opening the QTP, so that
one can select the desired add inn’s and make the QTP compatible with those environments. With the default
purchase of QTP, 3 built in add inn’s will be provided:
1. ACTIVE X
2. VISUAL BASIC
3. WEB
By default QTP will be always compatible with standard windows environment. Apart from the above add inn’s any
other add inn’s are required, one need to purchase them separately.
Note: HP people also provides single license for all the add inn’s.
PARTS OF QTP:
1.TEST PANE
2.ACTIVE SCREEN
3.DATA TABLE
4.DEBUG VIEWER PANE
5.INFORMATION PANE
6.MISSING RESOURCES PANE
7.TOOL OPTIONS
1. TEST PANE: Test pane is an area provided by the QTP, which is used for developing, viewing, and modifying the
test script.
1. ITEM
2. OPERATION
3. VALUE
4. DOCUMENTATION
Note: Any modifications done in one view will be reflected in the other view.
2. ACTIVE SCREEN: Active screen is an a area provided by QTP, which holds the snapshots related to each and every
recorded scripts statements and used for easily understanding and enhancing the scripts.
NAVIGATION:
a. Activate the menu item Automation.
b. Select the option RECORD and RUN settings.
c. Select the desired Environment tab.
d. Select the required Option.
e. Click on Apply and OK.
RECORDING MODES:
There are 3 types of Recording Modes:
1. NORMAL/CONTEXT SENSITIVE RECODING MODE.
2. ANALOG RECORDING MODE.
3. LOW LEVEL RECORDING MODE.
NAVIGATION:
a) Keep the tool under normal recording mode.
b) Activate the menu item automation.
c) Select the option analog recording.
d) Select one of the following options:
o Record relative to the screen.
o Record relative to the following window.
If at all second option is selected, specify the window title with the help of hand icon, click on start analog
record button.
Ex: Following Script will be produced for Paint Brush depending upon the above Option selected:
Record relative to the screen: Desktop.Runanalog’Track1’
Where as Track1 is the internal file used for recording the actions performed by the user.
OBJECT REPOSITORY:
It is a storage place, where one can store the object information and it is also acts as an interface between
the Test Script and AUT (Application Under Test), In order to identify the objects during execution.
LOCAL REPOSITORY: For each and every action in a Test (SCRIPT FILE). One separate local repository will be created
and managed by QTP automatically. The information present in the local repository can be used by that action.
SHARED REPOSITORY: Whenever we feel that same common objects information need to shared by so many actions
present in the different Tests (SCRIPT FILE), then it is suggested to create a shared repository with that common
information and associate it to all required actions.
By doing like this the advantage is, if any modifications are required in future than it is very easy.
Note: We can associate one (or) more shared repositories to an action apart from its local repository.
NAVIGATION FOR CREATING SHARED REPOSITORY WHENEVER THE INFORMATION ALREADY AVAILABLE IN THE LOCAL REPOSITORY:
Open the Object Repository.
Activate the Menu item File in Object Repository.
Select the option Export Local Objects.
Browse the desired location and SAVE with .TSR extension.
NAVIGATION FOR ASSOCIATING THE SHARED REPOSITORY TO AN ACTION:
Activate the Menu item Resources.
HIGHLIGHTING THE APPLICATION: This option is used for highlighting the corresponding object in the application,
upon selecting the object name in the Object Repository.
LOCATING THE REPOSITORY: This option is used for locating the object name in the Object Repository, upon
specifying the corresponding object in the application.
OBJECT IDENTIFICATION:
The object identification concept is based on 4 types of properties and an Ordinal Identifier.
One can specify a list of properties under Mandatory section, list of properties under
Assistive section, list of properties under the Base Filter section, list of properties under the Optional Filter section
and an Ordinal Identifier.
QTP WILL LEARN THE INFORMATION IN THE FOLLOWING WAY, INCASE OF ONLY NORMAL IDENTIFICATION:
First of all QTP will learn all the Mandatory properties, it will think whether those
properties are sufficient or not, if it feels not sufficient, then it will learn 1st Assistive property, and then once again
think whether all those properties are sufficient for identifying the object uniquely, if it feels not sufficient it will
nd
learn the 2 Assistive property and once again think whether they are sufficient or not, if not sufficient then it will
repeat the same process by learning the next Assistive properties one by one till it feels satisfy, if not all the Assistive
properties are learned, still QTP not satisfy then finally it will learn the Ordinal Identifier, whatever learned during
the above process will be stored in the object repository.
QTP WILL LEARN THE INFORMATION IN THE FOLLOWING WAY, INCASE OF SMART IDENTIFICATION ALSO:
QTP will learn all the Mandatory properties, all the Base Filter properties, all the
Optional Filter properties at a time, stores the Base Filter properties and Optional Filter properties in a secrete place
and will not think about them. It will think whether the Mandatory properties are sufficient for identifying the object
uniquely, if it feels not sufficient, it will learn the first Assistive property and continues the process same as above.
Ex:
QTP WILL LEARN THE INFORMATION IN THE FOLLOWING WAY DURING THE IDENTIFICATION:
First of all it will use all the properties present in the object repository and will try to identify the
object, if it fails then it will use Smart Identification mechanism and will try to identify the object finally as follows:
First it will use all the Base Filter properties and will try to identify the object, if at all more then
one objects are found, it will consider those objects and filters all the remaining objects.
It will take the first Optional Filter property and will try to identify the object in the considered
objects, if at all more than one matches are found then it will consider only those objects and filters the remaining
objects, then it will take the second Optional Filter property and repeats the same process till it finds exactly one
match or one object.
In case all the Optional Filter properties are used but still QTP is unable to find exactly one match,
then it will go to Object Repository and check whether the Ordinal Identifier is available or not, if it is available using
that it will roughly identify the object otherwise hands up.
Ex:
While learning the properties it will stops still it satisfies that it is enough for identifying the objects and stores the
information in the Normal Identification, then what the use of Smart Identification?
DISABLE
E
While learning for example in the Login screen first LOGIN and CLEAR buttons are DISABLED.
ENABLE
While identifying the objects, suppose user enters UN and PW, then the LOGIN and CLEAR buttons are ENABLED.
So the properties of LOGIN and CLEAR buttons are varying, so it is difficult to identify the objects with the learned
properties in the Normal Identification, so it will go for Smart Identification for identifying the objects.
Ex:
Why can’t we specify object name as the property for identifying the objects very easily?
Suppose the application has dynamic button, then it will change its behavior depending upon the user action.
BEFORE
AFTER
DYNAMIC BUTTON
So it is difficult for identifying the object with the object name property.
Ex: Configuration of the objects that are identified should not change, it will affect the remaining objects, in case if
any object is not identified, then try to change the properties of those objects in the object repository.
ORDINAL IDENTIFIER:
There are 3 types of Ordinal Identifier’s:
1.LOCATION
2.INDEX
3.CREATION TIME
1. LOCATION: Whenever the Location is selected as an Ordinal Identifier. QTP will generate some numbers like 0, 1,
2, 3………. based on the sequence of the objects located in the application.
2. INDEX: Whenever the Index is selected as an Ordinal Identifier. QTP will generate some numbers like 0, 1, 2,
3………. based on the index of the pages related to those objects.
3. CREATION TIME (FOR BROWSER OBJECT IN WEB ENVIRONMENT ONLY): Whenever the Creation Time is selected as an
Ordinal Identifier. QTP will generate some numbers like 0, 1, 2, 3………. based on the loading time of the objects in
the browser.
OBJECT SPY: It is a handy feature provided by the QTP, which shows complete object information like list of object
properties and values, list of methods, syntax of methods, description of methods of both the Test objects and Run
Time objects then and there on the spot immediately.
NAVIGATION:
Activate the menu item Tools.
Select the option Object Spy.
Specify the desired object in the application with the help of handy icon.
TYPES OF OBJECTS:
There are 2 types of objects:
1. RUN TIME OBJECTS
2.TEST OBJECTS.
1. RUN TIME OBJECTS: All the original objects present in the application are known as Run Time objects.
2. TEST OBJECTS: The reference objects for the original objects present in the object repository are known as Test
objects.
1. TEST PLANNING:
In this phase the Automation Test Lead will do the following:
He will understand the Requirements.
He will identify the area to be Automated.
He will analyze the dynamism of the application and based on that he will do all the pre configurational settings to
that tool, in such a way that it will be compatible to that application.
He will do the Resource planning (Who has to do what?).
He will do the Scheduling.
He will prepare the Automation Test Plan document with all the above analyzed information.
CHECK POINT: Check point is a feature provided by the QTP, which is used for checking something during the
execution, at any point of time.
TYPES OF CHECKPOINTS:
1.STANDARD CHECKPOINT
2.BITMAP CHECKPOINT
3.TEXT CHECKPOINT
4.TEXT AREA CHECKPOINT
5.DATABASE CHECKPOINT
6. XML CHECKPOINT (FROM RESOURCE)
7.PAGE CHECKPOINT
8.TABLE CHECKPOINT
9.IMAGE CHECKPOINT
10. ACCESSIBILITY CHECKPOINT
1. STANDARD CHECKPOINT:
It is used for checking the standard GUI objects properties values.
It can be inserted in 2 ways:
1. Through Application
2. Through Active Screen
BITMAP CHECKPOINT:
It is used for checking the expected pixels are present in the selected area of the application (or) not.
It is also used for checking the complete Bitmap (or) a part of the Bitmap.
One can insert the Bitmap check point through Application (or) Active screen
BITMAP: It is a particular area, where it stores some pixels, we can’t do any actions on it.
IMAGE: We can do some actions on it, we can use it as a Hyperlink/Object.
TEXT CHECKPOINT: It is used for checking the text present on the specified objects, it can be inserted through
Application as well as through Active Screen.
NAVIGATION THROUGH APPLICATION:
Keep the cursor in the desired location.
Keep the tool under Recording.
Activate the menu item Insert.
Go to the CheckPoint.
Select the option Text CheckPoint.
Specify the desired object by using hand icon.
Click on OK.
Specify the desired expected text in the Application.
Select the Required option:
Match case Ignore spaces
Exact match Text not displayed
Click on OK.
Stop Recording.
WIZARD: It is a group of windows, which accepts some information from the user and accomplishes the task in a complex way.
Ex: Create a file with .XML with the help of notepad as follows:
<ENVIRONMENT>
<VARIABLE>
<VAR>
<NAME>
SURI
</NAME>
</VAR>
</VARIABLE>
<VARIABLE>
<VAR>
<NAME>
RAVI
</NAME>
</VAR>
</VARIABLE>
</ENVIRONMENT>
NAVIGATION:
Keep the cursor on the desired statement.
Go to Active Screen.
Right click on the screen.
Select the option insert Standard CheckPoint.
Select the page in the Hierarchy.
Click on OK.
Select the desired properties to be checked.
Select one of the following options:
o Before current step
o After current step
Click on OK.
NAVIGATION:
Keep the cursor on the desired statement.
Go to Active Screen.
Right click on the screen.
Select the option insert Standard CheckPoint.
Select the page in the Hierarchy.
Click on OK.
Select the desired properties to be checked.
Select one of the following options:
oBefore current step
oAfter current step
Click on OK.
NAVIGATION:
Keep the cursor on the desired statement.
Go to Active Screen.
Right click on the screen.
Select the option insert Standard CheckPoint.
Select the page in the Hierarchy.
Click on OK.
Select the desired properties to be checked.
Select one of the following options:
oBefore current step
oAfter current step
Click on OK.
WEB CHECK POINTS: PAGE, TABLE AND IMAGE CHECK POINTS ARE HIDDEN CHECK POINTS, WE CAN USE ONLY THROUGH STANDARD CHECK POINT.
ACCESSABILITY CHECKPOINT: It is used for checking whether the page is developed according to the WORLD WIDE
WEB CONSORTIUM (W3C) standards or not. With the help of these checkpoints one can confirm whether that page
can be accessible all over the world comfortably or not.
NAVIGATION:
Keep the cursor on the desired statement.
Go to Active Screen.
Right click on the page.
Select the option insert Accessibility CheckPoint.
Select one of the following options:
oBefore current step
oAfter current step
Click on OK.
SYNCHRONIZATION: It is a process of matching the speeds of both the tool and the application in order to keep them
in sync with each other, in order to obtain proper Testing results.
Here the main concept is making the tool to wait, till the application finishes its work, to do the
same we can follow any one of the following way:
1. Inserting the synchronization point statement.
2. Increasing the default time.
3. Inserting the wait statement.
Note: Synchronization point statement affects only one statement, it adds the time specified with the default time.
To avoid the above navigation, one can directly insert the following statement:
SYNTAX:
HIERARCHY.WAITPROPERTY”PROPETY NAME”, PROPERTY VALUE, EXTRA TIME IN MILLISECONDS
Ex:
WINDOW(“FLIGHT RESERVATION”).WINBUTTON(“DELETE ORDER”).WAITPROPERTY”ENABLED”, TRUE, 14000
Note: It effects only one statement, but it will wait till the time is finished, even though the action is completed.
VARIABLE: It is a name given to the memory location, which can hold some value, it can change values in any
number of times if required.
PARAMETRIZATION: It is a process of replacing the constant values with variables in order to increase the scope of
test.
PARAMETRIZATION: It is a process of replacing the constant values with variables or parameters, in order to increase
the scope of test.
Parameterization can be done in 3 ways:
1.DATA DRIVEN WIZARD
2.KEYWORD VIEW
3.MANUALLY
TO AVOID THE ABOVE NAVIGATION, PARAMETERIZATION CAN BE DONE MANUALLY IN THE FOLLOWING WAY:
Ex:
X=DATA TABLE(“V1”,I)
VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET X
VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE2”).SET DATATABLE(“V2”,I)
VBWINDOW(“CALCULATOR”).VBEDIT(“ADD”).CLICK
OUTPUT VALUES: It is a feature provided by the QTP, which is used for capturing a value from an application (or)
from a Data Base (or) from a XML files and stores it under a desired column in the Runtime Data table.
MEASURING TRANSACTIONS: It is a concept provided in QTP used for calculating the Time taken by an Application
approximately to perform a Task. (Or) Execution Time of block of script statements, to do the same QTP has
introduced START TRANSACTION & END TRANSACTION POINTS.
Ex:
SERVICES. START TRANSACTION <TRANSACTION NAME>
-----------------------------
-------------------------------
-------------------------
SCRIPT STATEMENTS
---------------------------
---------------------------------
--------------------------------
SERVICES. END TRANSACTION <TRANSACTION NAME>
Apart from the above Programmatic statements Comments also will be available in a program.
COMMENTS: Comments are used for increasing the readability of the script. It starts with single quote (‘).
Ex: ‘This Program is for Normal Recording.
SYSTEM UTIL UTILITY OBJECT: This utility object is mainly used for invoking the Application with the help of Run
method.
Syntax: SYSTEMUTIL.RUN “PATH”
Note: One can even invoke the application with the help of invoke application statement.
Syntax: INVOKEAPPLICATION “PATH”
REPORTER UTILITY OBJECT: It is used fro sending an extra result step to the result window.
Syntax: REPORTER.REPORTEVENT STATUS, “STEPNAME”, “DETAILS/MSG”
Ex:
REPORTER.REPORTEVENT MICDONE, “MYREP”, “ADD IS SUCCESSFUL”
(Or)
REPORTER.REPORTEVENT 0, “MYREP”, “ADD IS SUCCESSFUL”
STATUS: 0-PASS
1-FAILED
2-DONE
3-WARNING
BREAKPOINT: It is a feature provided by QTP which is used for breaking the execution temporarily.
STEP COMMANDS:
1. STEP INTO: It is used for executing a single step, if that step is a functional call step then it will make the pointer
step into the function and breaks the execution at the first statement.
2. STEP OUT: It is used only after entering into the function, it will execute all the remaining statements inside the
function from the position of the pointer and breaks the execution after stepping out of the function.
3. STEP OVER: This statement is used for executing any step until it is finished, for example if it is a functional call
statement it will execute all the statements inside the function and then breaks the execution.
4. RUN TO STEP: This is used for executing all the statements up to the before statement, where the cursor is
available.
5. DEBUG FROM STEP: This is used for bringing the pointer to a desired statement without executing any of the
previous statements.
Ex:
FUNCTION MYFUNC()
MSGBOX “HAI”
MSGBOX “HELLO”
MSGBOX “BYE”
END FUNCTION
‘ MAIN PROGRAM
MSGBOX “WELCOME”
CALL MYFUNC()
MSGBOX “SEE U”
MYFUNC()
MSGBOX “TA TA”
MYFUNC()
MSGBOX “TAKE CARE”
MSGBOX “HAPPY WEEKEND”
4. DEBUG VIEWER PANE: It is an area provided by the QTP, which is used for Viewing, Modifying (or) Setting the
current values of variables (or) expressions during the execution break with the help of 3 tabs by name WATCH,
VARIABLES & COMMAND.
Ex:
DIM A, B
A=10
B=20
MSGBOX A ---------------10_______COMMAND A=40
MSGBOX A ----------------40_______WATCH A*B
MSGBOX A ----------------800
5. EXECUTING THE TEST: In this phase one will execute the Test.
6. ANALYZING THE RESULT: In this phase one will analyze the Result.
RECOVERY SCENARIOS: During the execution sometimes QTP may face some problematic statements, where in it
need to recover by itself and should continue the execution, to do the same the test engineer need to define a
solution well in advance and attach it to the corresponding test before starting the execution.
To define the solutions for above problems QTP has provided 4 Trigger Events:
1. POP UP WINDOW
2. OBJECT STATE
3. TEST RUN ERROR
4. APPLICATION CRASH
NAVIGATION FOR ASSOCIATING THE EXISTING RECOVERY SCENARIO TO THE CURRENT TEST:
Activate the menu item file.
Select the option settings.
Select the recovery tab.
Click on add button.
Browse the desired recovery scenario.
Click on add scenario
Click on apply.
OK.
ENVIRONMENT VARIABLES:
Whenever some common values need to be used in multiple scripts then it is suggested not to declare the
local variables in all tests individually, it is better to declare all the common variables in a separate environment file,
attach it to all the required tests and use those variables inside those test.
By doing this the advantage is in future if the environment is changed and some of the values of those
variables need to be updated in order to make the scripts compatible with that environment, then with minimum
efforts, we can update the values in the environment file instead of updating all the script files.
1. BUILT IN VARIABLES: These variables by default will be available with every new test, so any one can use them
directly in any test using the following syntax:
2. USER DEFINED VARIABLES: Whenever we feel that we no need some common variables, to develop number of
scripts depending upon our application, then we must declare the user defined variables in a separate environment
file, attach that file to the required test and use those variables inside those tests.
To avoid the above navigation one can directly develop the environment file as follows:
To avoid the above navigation one can directly write the script statements with following syntax:
ENVIRONMENT.LOADFROMFILE”PATH OF ENVIRONMENT FILE”
Ex: ENVIRONMENT.LOADFROMFILE”E:\envfile.xml”
PATH=ENVIRONMENT.VALUE(“PATH”)
X=ENVIRONMENT(“A”)
Y=ENVIRONMENT(“B”)
SYSTEMUTIL.RUN PATH
VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET X
VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE2”).SET Y
VBWINDOW(“CALCULATOR”).VBBUTTON(“SUB”).CLICK
MSGBOX “WELCOME”
MYFUNC()
MSGBOX “BYE”
FRAMEWORK: It is defined as a generic work or a set of guidelines to perform a task in an effective, efficient and
optimized way.
Types of Frameworks:
1.LINEAR FRAMEWORK
2.MODULAR FRAMEWORK
3.KEYWORD DRIVEN FRAMEWORK
4.HYBRID FRAMEWORK
5.DATA DRIVEN FRAMEWORK
1. LINEAR FRAMEWORK:
Generate the basic script for the required end to end scenario.
Enhance the script.
Debug the script.
Execute the script.
Analyze the script.
2. MODULAR FRAMEWORK:
Develop the individual components for the tasks which need to be repeatedly perform.
Make them as reusable components.
Prepare the driver scripts for the end to end scenarios.
Execute the driver scripts.
Analyze the results.
Types of Actions:
1. NORMAL
2. REUSABLE
Ex:
Record the Flight reservation application.
Split the script as Action1 (LOGIN), Action2 (INSERT ORDER), Action3 (OPEN ORDER), Action4 (LOGOUT).
Save the script.
Open a new file.
Call the existing Actions.
Enhance the script if necessary.
Run the script.
PROJECT NAME_AUTOMATION
TD
REP
LIB
REC
ENV
TEST
LOG
TD-TEST DATA
REP-REPOSITORY
LIB-LIBRARY
REC-RECOVERY
ENV-ENVIRONMENT
TEST-SCRIPT FILES
LOG-HIGH LEVEL RESULT FILES
TEST LOG: It is a chronological record of all relevant details about the execution of a Test.
NAVIGATION:
Develop the required Test Data Files, Repository Files, Library Files, Recovery Files and Environment Files and
save them in corresponding folders.
Open the main Test and associate all the required resources.
Develop the script in such a way that it is executed based on the keywords specified in the Data Table.
Save the script in the corresponding folder.
Whenever required open the script.
Specify the desired keywords.
Execute the script and analyze the result.
Add objects information in the object repository through Add Objects to Local or through Shared Repository.
For invoking the application we use SYSTEMUTIL.RUN statement.
Create a library file with .VBS extension through notepad as follows:
FUNCTION LOGIN()
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "suri"
Dialog("Login").WinEdit("Password:").SetSecure "4b55acb065483d2d7c0ba692c91a3baabd597428"
Dialog("Login").WinButton("OK").Click
END FUNCTION
FUNCTION INSORD()
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
FUNCTION OPNORD()
Window("Flight Reservation").WinButton("Button_2").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "5"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
END FUNCTION
FUNCTION LOGOUT()
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
END FUNCTION
CASE "L1"
CALL LOGIN()
CASE "L2"
CALL INSORD()
CASE "L3"
CALL OPNORD()
CASE "L4"
CALL LOGOUT()
END SELECT
4. HYBRID FRAME WORK: It is a mixture of two or more frameworks is known as Hybrid Framework.
LIBRARY FILES: It is an area provided by QTP, where one can develop and store the user define functions.
DIFFERENCES:
a) Win runner is a Functional testing tool
b) Load runner is Performance tool
c) Test director is Management tool
d) Silk test is a Functional testing tool
a) Win runner:
1. You can record the script automatically or manually you can write scripts.
2. This is mainly use for Regression testing.
b) Load runner:
1. This tool is mainly used for Performance testing.
2. We can also use this tool for Load testing and Stress Testing
c) Test director:
1. This is a Management tool.
2. Test director tool contains:
a. Test Plan
b. Test Cases
c. Time estimation
d. Schedule documents
e. Bug Lists
d) Silk test:
1. Silk Test is a tool specifically designed for doing Regression and Functionality testing.
2. It is developed by Segue Software Inc.
3. Silk Test is the industry’s leading functional testing product for e-business applications,
whether Window based, Web, Java, or traditional client/server-based.
4. Silk Test also offers test planning, management, direct database access and validation, the
flexible and robust for Test scripting language.
5. A built in recovery system for unattended testing, and the ability to test across multiple
platforms, browsers and technologies.
VB SCRIPT
VARIABLE: It is a name given to a memory location, which can hold a value and that can be changed any number of
times in future if required.
Declaration of a Variable:
One can declare the Variables in VB Script using the following Keywords:
DIM
PRIVATE
PUBLIC
Option EXPLICIT: Option EXPLICIT statement restricts the usage of new variables in the program without declaration.
Whenever a new variable is found during the execution immediately an error will be shown, if at all the option
Explicit statement is not used any misspelled variable name also will be treated as new variable.
CONSTANT: It is a name given to a memory location , which can hold a value that can’t be changed in future.
OPERATORS:
1. ARTHIMATIC OPERATORS:
+ Ex: a+b
- Ex: a-b
* Ex: a*b
MOD Ex: 20 MOD 7=6
^ Ex: 10 ^ 2=100
2. ASSIGNMENT OPERATOR:
= Ex: a=10
3. CONCATINATION OPERATOR:
& Ex: var=”Suri”
Msgbox ‘My name is:”& var
4. COMPARISION OPERATORS:
<
>
<=
>=
=
<>
5. LOGICAL OPERATORS:
AND
OR
XOR
NOT
TRUTH TABLES:
AND
EXP1 EXP2 RESULT
T T T
T F F
F T F
F F F
OR
EXP1 EXP2 RESULT
T T T
T F T
F T T
F F F
XOR
EXP1 EXP2 RESULT
T T F
T F T
F T T
F F F
NOT
EXP RESULT
T F
F T
CONDITIONAL STATEMENTS:
1. IF---THEN---ELSE: It is used for executing either TRUE block or FALSE block of statements based on the condition.
Syntax: IF <CONDITION> THEN
---------------------
-------------------
ELSE
----------------
------------------
ENDIF
2. SELECT-CASE STATEMENT: Whenever we want to execute a particular block of statements among many blocks
then we will choose select case statement.
Syntax: SELECT CASE var
CASE1
-----------
---------
CASE2
---------
----------
ELSE CASE
----------
----------
END SELECT
LOOPING STATEMENTS:
Looping statements are used for executing a certain block of statements repeatedly and continuously for some
number of times.
1. FOR---NEXT: It is used for executing a block of statements repeatedly for certain number of times.
Syntax: FOR I=1 TO 10 STEP 1
----------------
-------------
NEXT
2. WHILE-----WEND: It is used for executing a block of statements repeatedly as long as the condition is being
satisfied.
Syntax: WHILE <CONDITION>
------------
------------
WEND
3. DO WHILE---LOOP: It is used for executing a block of statements repeatedly as long as the condition is being
satisfied.
Syntax: DO WHILE <CONDITION>
----------------
--------------
LOOP
4. DO-----LOOP WHILE: It is used for executing a block of statements repeatedly as long as the condition is being
satisfied, but first time execution will be done without checking the condition.
Syntax: DO
-------------
--------------
LOOP WHILE <CONDITION>
5. DO UNTIL----LOOP: This loop is used for executing the block of statements repeatedly as long as the condition is
not being satisfied.
Syntax: DO UNTIL <CONDITION>
------------
-----------
LOOP
6. DO----LOOP UNTIL: This loop is used for executing the block of statements repeatedly as long as the condition is
not being satisfied, but first time execution will be done without checking the condition.
Syntax: DO
-----------
------------
LOOP UNTIL <CONDITION>
PROCEDURES: Procedures are used for reusability, whenever we want a task need to be performed again and again
many number of times in different situations and also may be in different programs then we will prepare one
procedure for that task and call that procedure any number of times in any number of programs.
1. Function Procedures can return a value, but Sub Procedures can’t returns a value.
2. Sub Procedures will be executed more faster then Function Procedures, so whenever we no need to return any
value, it is better to use Sub Procedure.
MAIN PRG:
VAR=ADD(10,20)
--------------
---------------
VAR1=ADD(20,30)
---------------
------------------
MAIN PRG:
---------------------
------------------
LOGIN(“SURI”,”TESTING”)
----------------
----------------------
LOGIN(“RAVI”,”ENG”)
--------------
-----------------
1. CAPTURE BITMAP: It is a method used for capturing the snapshot of any object and storing it in the desired
location during the execution.
Syntax: OBJECT HIERARCHY.CAPTURE BITMAP ”PATH OF THE LOCATION WITH FILE NAME.BMP EXTENSION”
Ex: WINDOW(“FLIGHT RESERVATION”)DIALOG(“OPEN ORDER”)WINBUTTON(“OK”).CAPTUREBITMAP “D:\SURI\DEFECT.BMP”
2. EXIST: It is a method used for checking whether the object is existing or not, if at all the object is existing than it
will return a value TRUE otherwise it will make the QTP wait till the object exists, soon after the object exists it will
return a value TRUE and allows the QTP for further execution. In case the object doesn’t exist till the maximum time
(Default time + Extra time) specified than finally it will return FALSE and allows the QTP for further execution.
Syntax: VAR=OBJECT HIERARCHY.EXIST[(TIME IN SECONDS)]
Ex: VAR=OBJECT HIERARCHY.EXIST(15)
3. WAIT PROPERTY: It is a method used for making the tool to wait based on the objects properties value or up to
the maximum time.
Syntax: OBJECT HIERARCHY.WAIT PEOPERTY ”PROPERTYNAME”
Ex: WINDOW(“FLIGHT RESERVATION”).WINBUTTON(“DELETE ORDER”).WAIT PROPERTY “ENABLED”,TRUE,1400
4. WAIT: It is a method used for making the tool to wait till the specified time is elapsed.
Syntax: WAIT(TIME IN SECONDS)
EDIT BOX: It is a method used for setting any value into the edit box.
Syntax: OBJECT HIERARCHY.SET “VALUE”
Ex: SURENDRA
CHECK BOX: It is a method used for selecting or deselecting the check box.
Syntax: OBJECT HIERARCHY.SET “ON/OFF”
Ex:
RADIOBUTTON: It is a method used for selecting a radio button in a group of radio buttons.
Syntax: OBJECT HIERARCHY.SET
Ex:
CASE STUDY 1:
Develop the script for entering CID, CNAME, CAGE, CPHNO and click on SUBMIT.
VBWINDOW(“CUST”).VBEDIT(“CID”).SET “001”
VBWINDOW(“CUST”).VBEDIT(“CNAME”).SET “SURI”
VBWINDOW(“CUST”).VBEDIT(“CAGE”).SET “26”
VBWINDOW(“CUST”).VBEDIT(“CPHNO”).SET “9985621122”
VBWINDOW(“CUST”).VBBUTTON(“SUBMIT”).CLICK
CASE STUDY 2:
Develop the script for selecting the STE, ISTQB, and SQL SERVER check boxes and clicking on NEXT button.
SRSS:
STE
QTP
LR
LIVE PROJECT
ISTQB
SQL SERVER
NEXT
VBWINDOW(“SRSS”).VBCHECKBOX(“STE”).SET “ON”
VBWINDOW(“SRSS”).VBCHECKBOX(“ISTQB”).SET “ON”
VBWINDOW(“SRSS”).VBCHECKBOX(“SQL SERVER”).SET “ON”
VBWINDOW(“SRSS”).VBCHECKBOX(“NEXT”).SET “ON”
CASE STUDY 3:
Develop the script for deselecting the STE check box, selecting the QTP and LIVE PROJECT check boxes and clicking on
NEXT button.
SRSS:
STE
QTP
LR
LIVE PROJECT
ISTQB
SQL SERVER
NEXT
VBWINDOW(“SRSS”).VBCHECKBOX(“STE”).SET “OFF”
VBWINDOW(“SRSS”).VBCHECKBOX(“ISTQB”).SET “ON”
VBWINDOW(“SRSS”).VBCHECKBOX(“SQL SERVER”).SET “ON”
VBWINDOW(“SRSS”).VBCHECKBOX(“NEXT”).SET “ON”
CASE STUDY 4:
Develop the script for entering the COUNTRY, AGE, GENDER, selecting the check box PHOTO PROFILES ONLY and
clicking on SEARCH button.
MATRIMONY:
COUNTRY:
AGE:
MALE
FEMALE
SEARCH
VBWINDOW(“MATRIMONY”).VBEDIT(“COUNTRY”).SET “INDIA”
VBWINDOW(“MATRIMONY”).VBEDIT(“AGE”).SET “26”
VBWINDOW(“MATRIMONY”).VBRADIOBUTTON(“FEMALE”).SET
VBWINDOW(“MATRIMONY”).VBCHECKBOX(“PHOTO PROCESS ONLY).SET “ON”
VBWINDOW(“MATRIMONY”).VBBUTTON(“SEARCH”).CLICK
8. SELECT: It is a method used for selecting an item from a combo box or list box.
Syntax: OBJECT HIERARCHY.SELECT “ITEM”
CASE STUDY 5:
Develop the script for entering TRAIN NO, TRAIN NAME, and selecting the STARTING POINT and DESTINATION, entering the DOJ,
selecting the CLASS, BIRTH, selecting the BREAKFAST, LUNCH, or DINNER checkboxes and clicking on NEXT.
RESERVATION:
TRAIN NO:
TRAIN NAME:
FROM:
TO:
DOJ:
FIRST A/C UB
SECOND A/C MB
SLEEPER LB
BREAKFAST
LUNCH
DINNER
SEARCH
VBWINDOW(“RESERVETION”).VBRADIOBUTTON(“FIRST A/C”).SET
VBWINDOW(“RESERVETION”).VBRADIOBUTTON(“UB”).SET
VBWINDOW(“RESERVETION”).VBCHECKBOX(“BREAKFAST”).SET “ON”
VBWINDOW(“RESERVETION”).VBCHECKBOX(“LUNCH”).SET “ON”
VBWINDOW(“RESERVETION”).VBCHECKBOX(“DINNER”).SET “ON”
VBWINDOW(“RESERVETION”).VBBUTTON(“NEXT”).CLICK
11. TYPE: It is a method used for performing the keyboard related operations
Syntax: OBJECT HIERARCHY.TYPE “KEY VALUE”
Ex: OBJECT HIERARCHY.TYPE MICTAB
12. SET SECURE: It is a method used for setting the encrypted data into the edit box.
Syntax: OBJECT HIERARCHY.SET SECURE “ENCRYPTED STRING”
NOTE: To generate the encrypted string QTP has provided special tool by name PASSWORD ENCODER.
NAVIGATION: START------>PROGRAMS-------->QTP-----TOOLS----------->PASSWORD ENCODER.
13. GET RO PROPERTY: It is A method used for getting the run time objects properties value during the execution.
Syntax: VAR=OBJECT HIERARCHY.GETROPROPERTY (“PROPERTY NAME”)
14. GET TO PROPERY: It is a method used for getting the test objects properties value.
Syntax: OBJECT HIERARCHY.GETTOPROPERTY (“PROPERTY NAME”)
CASE STUDY 6:
Develop the script for clicking on OK button, if it is existing and enabled.
FORM:
OK
VAR=VBWINDOW(“FORM”).VBBUTTON(“OK”).EXIST
IF (VAR=TRUE) THAN
VAR1= VAR=VBWINDOW(“FORM”).VBBUTTON(“OK”).GETROPROPERY (“ENABLED”)
IF (VAR1=TRUE) THAN
VAR=VBWINDOW(“FORM”).VBBUTTON(“OK”).CLICK
ELSE
REPORTER.REPORTEVENT 3,”MYREP”,”OK BUTTON IS DISABLED”
ENDIF
ELSE
REPORTER,REPORTEVENT 3,”MYREP”,”OK BUTTON IS NOT EXIST”
ENDIF
CASE STUDY 7:
Develop the script for selecting the PID, entering the QUANTITY, PNAME, RATE, clicking on CAL button and checking
whether it is working fine or not.
PRODUCT:
PID:
PNAME:
PRATE:
QUANTITY:
AMOUNT:
CAL
VBWINDOW(“PRODUCT”).VBCOMBOBOX(“PID”).SELECT “007”
Q=6
R= VBWINDOW(“PRODUCT”).VBEDIT(“PRATE”).GETROPROPERY(“TEXT”)
EV=R*Q
VBWINDOW(“PRODUCT”).VBEDIT(“QUANTITY”).SET Q
VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).CLICK
AV= VBWINDOW(“PRODUCT”).VBEDIT(“AMOUNT”).GETROPROPERTY(“TEXT”)
IF(EV=AV) THEN
REPORTER.REPORTEVENT 0,”MYREP”,”CAL BUTTON WORKING PROPERLY”
ELSE
REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON NOT WORKING PROPERLY”
ENDIF
CASE STUDY 8:
Develop the script for selecting the PID, entering the QUANTITY, PNAME, RATE, clicking on CAL button, if it is existing
and enabled and checking whether the CAL button is working properly or not.
PRODUCT:
PID:
PNAME:
PRATE:
QUANTITY:
AMOUNT:
CAL
VBWINDOW(“PRODUCT”).VBCOMBOBOX(“PID”).SELECT “007”
Q=2
VBWINDOW(“PRODUCT”).VEDIT(“QUANTITY”).SET Q
RATE= VBWINDOW(“PRODUCT”).VBEDIT(“PRATE”).GETROPROPERY(“TEXT”)
EV=RATE*Q
V1=VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).EXIST
IF(V1=TRUE) THEN
ENV= VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).GETROPROPERTY(“ENABLED”)
IF(ENV=TRUE) THEN
VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).CLICK
ACTVAL=VBWINDOW(“PRODUCT”).VBEDIT(“AMOUNT”).GETPROPERTY.”TEXT”
IF(ACTVAL=EV) THEN
REPORTER.REPORTEVENT 0,”MYREP”,”CAL BUTTON WORKING PROPERLY”
ELSE
REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON NOT WORKING PROPERLY”
ENDIF
ELSE
REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON IS ENABLED”
ENDIF
ELSE
REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON IS NOT EXIST”
ENDIF
CASE STUDY 9:
Develop the script for entering 10 into VAL1, 20 into VAL2 and clicking on ADD button, if it is existing, enabled and
checking whether it is working properly or not.
CAL:
VAL1:
VAL2:
RESULT:
ADD
VBWINDOW(“CAL”).VBEDIT(“VAL1”).SET “10”
VBWINDOW(“CAL”).VBEDIT(“VAL1”).SET “20”
EV=30
V1= VBWINDOW(“CAL”).VBBUTTON(“ADD”).EXIST
IF(V1=TRUE) THEN
V2= VBWINDOW(“CAL”).VBBUTTON(“ADD”).GETROPROPERTY “ENABLED”
IF(V2=TRUE) THEN
VBWINDOW(“CAL”).VBBUTTON(“ADD”).CLICK
AV= VBWINDOW(“CAL”).VBEDIT(“RESULT”).GETROPROPERTY “TEXT”
IF(CINT(AV)=CINT(EV)) THEN
REPORTER.REPORTEVENT 0,”MYREP”,”ADD BUTTON WORKING PROPERLY”
ELSE
REPORTER.REPORTEVENT 1,”MYREP”,”ADD BUTTON NOT WORKING PROPERLY”
ENDIF
ELSE
REPORTER.REPORTEVENT 1,”MYREP”,”ADD BUTTON IS ENABLED”
ENDIF
ELSE
REPORTER.REPORTEVENT 1,”MYREP”,”ADD BUTTON DOESN’T EXIST”
ENDIF
15. SET TO PROPERTY: It is a method used for setting the test objects properties value temporarily during the
execution.
Syntax: OBJECT HIERARCHY.SETTOPROPERTY “PROPERTY NAME”, “PROPERTY VALUE”
OR
FORM:
FORM
DBUTTON
START
NATIVE CLASS-BUTTON
TEXT-START
DYNAMIC BUTTON
VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).CLICK
VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).SETTOPROPERTY “TEXT”, “STOP”
VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).CLICK
VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).SETTOPROPERTY “TEXT”, “START”
VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).CLICK
Ex:
IF (CINT(EV)=CINT(LTRIM(AV))) THEN
---------------------
-----------------
ELSE
-----------------
---------------------
ENDIF
Ex:
VAR=”SURENDRA”
VAR1=LEFT(VAR,4)-----------SURE
VAR2=RIGHT(VAR,3)---------DRA
VAR3=MID(VAR,3,3)---------REN
VAR4=MID(VAR,2,4)---------UREN
VAR5=LEN(VAR)---------------8
12. UCASE: It is used for converting the string into upper case.
13. LCASE: It is used for converting the string into lower case.
14. ROUND: It is used for rounding a value to the nearest integer.
BATCH TESTING/EXECUTION: It is a concept provided in QTP used for executing the group of script files continuously
at a time. To do the same QTP has provided a special tool by name TEST BATCH RUNNER. By using it one can create
the batch files and execute them comfortably.
Note: BATCH FILE EXTENSION IS .MTB (MERCURY TEST BATCH/MODULE TEST BATCH).
Note: BATCH TESTING CONCEPT IS USALLY USED DURING REGRESSION TESTING.
NAVIGATION:
START----->PROGRAMS------>QTP--------->TOOLS----->TEST BATCH RUNNER.
QTP----->TOOLS----->OPTIONS------>RUN------>CHECK [ALLOW THE MERCURY PRODUCTS TO RUN TEST AND COMMANDS].
3. DATA TABLE METHODS: Data Table Methods are used for making the QTP perform operations on the runtime
data table during the execution.
1. ADD SHEET: It is used for adding an extra sheet to the runtime data table.
Syntax: DATATABLE.ADD SHEET “SHHET NAME”
2. DELETE SHEET: It is used for deleting a specified sheet from runtime data table.
Syntax: DATATABLE.DELETE SHEET “SHEET NAME”
3. IMPORT: It is used for importing the complete data present in the excel file to the run time data table.
Syntax: DATATABLE.IMPORT “PATH OF THE EXCEL FILE”
4. IMPORT SHEET: It is used for importing the specified sheet of data from excel file to a specified sheet in the run
time data table.
Syntax: DATATABLE.IMPORT SHEET “PATH OF THE EXCEL FILE”, “SOURCE SHEET ID”,”DESTINATION SHEET ID”
5. EXPORT: It is used for capturing all the sheets of data present in the run time data table to an excel file.
Syntax: DATATABLE.EXPORT “PATH OF THE EXCEL FILE”
6. EXPORT SHEET: It is used for exporting a specified sheet of data from the run time data table to an excel file.
Syntax: DATATABLE.EXPORT SHEET “PATH OF THE EXCEL FILE”,”SHEET ID TO BE EXPORTED”
7. SET CURRENT ROW: It is used making the QTP focus on specified row.
Syntax: DATATABLE.SETCURRENTROW(ROW NUMBER)
8. SET NEXT ROW: It is used for making the QTP focus on the next row of the currently focused row.
Syntax: DATATABLE.SETNEXTROW
9. SET PREV ROW: It is used for making the QTP focus on the previous row of the currently focused row.
Syntax: DATATABLE.SETPREVROW
10. VALUE: It is used for getting the value from the specified sheet, specified column and the currently focused row.
Syntax: VAR=DATATABLE(“COLUMN NAME”,”SHEET ID”/”SHEET NAME”)
11. GET SHEET: it is used for making the QTP focus on a specified sheet.
Syntax: DATATABLE.GETSHEET(SHEET ID)
12. GET ROW COUNT: It is used for getting the row count of any specified sheet. By default it will get the row count
of global sheet, if we don’t focus any sheet.
Syntax 1: VAR=DATATABLE.GETROWCOUNT
Syntax 2: VAR=DATATABLE.GETSHEET(SHEET ID).GETROWCOUNT
Ex:
DATATABLE.ADDSHEET “SURENDRA”
DATATABLE.IMPORTSHEET “D:\SURI\TD1.XLS”,1,3
N=DATATABLE.GETSHEET(3).GETROWCOUNT
FOR I=1 TO N
DATATABLE.SETCURRENTROW(I)
VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET DATATABLE(“V1”,3)
VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET DATATABLE(“V2”,3)
VBWINDOW(“CALCULATOR”).VBBUTTON(“ADD”).CLICK
ACTVAL= VBWINDOW(“CALCULATOR”).VBEDIT(“RESULT”).GETPROPERTY(“TEXT”)
EXPVAL=DATATABLE(“EV”,3)
IF(CINT(EXPVAL)=CINT(ACTVAL)) THEN
REPORTER.REPORTEVENT 0,”MYREP”,”ADD OPERATION IS SUCCESS”
DATATABLE(“RES”,3)=”PASS”
ELSE
REPORTER.REPORTEVENT 0,”MYREP”,”ADD OPERATION IS NOT SUCCESS”
DATATABLE(“RES”,3)=”FAIL”
ENDIF
NEXT
DATATABLE.EXPORTSHEET “D:\SURI\LOG\LOGFILE1.XLS”,3
DATATABLE.DELETESHEET “SURENDRA”
CHECK SYNTAX: It is a feature provided by QTP used for checking the syntax in our script or program.
5. INFORMATION PANE: It is an area provided by QTP, which is used for viewing the syntax related information
during the syntax check.
6. MISSING RESOURCES PANE: While opening any test, if at all any attached resources are missing then that
information will be shown in the missing resources pane.
10 CTRL+P PRINT
11 CTRL+Z UNDO
12 CTRL+Y REDO
13 CTRL+C COPY
14 CTRL+V PASTE
15 CTRL+X CUT
16 DELETE DELETE
17 CTRL+I INSERT
18 CTRL+K DELETE
25 CTRL+F FIND
26 CTRL+H REPLACE
27 CTRL+G GOTO
29 F7 STOP GENERATOR
32 F3 RECORD
33 F5 RUN
34 F4 STOP
44 F9 INSERT/REMOVE BREAKPOINT
64 SHIFT+TAB TO MOVE THE FOCUS LEFT OR RIGHT WITH IN A SINGLE ROW, UNLESS YOU ARE IN A CELL
THAT IS IN A EDIT MODE, AND THEN YOU CAN USE TAB KEYS
67 ALT+F+X EXIT
68 F1 HELP
VIRTUAL OBJECT CONFIGURATION: It is a process of making the QTP to treat an user defined object or a specified
area in an application as a VIRTUAL OBJECT, once created VIRTUAL OBJECT will be permanently remembered by QTP,
unless until we delete them.
NAVIGATION:
Activate the menu item tools.
Go to Virtual Objects.
Select the option new Virtual Object.
Click on next.
Select the desired standard class.
Click on next.
Mark the object.
Click on next.
Select one of the following options:
oEntire parent hierarchy
oParent only
Click on next.
Specify the object name.
Specify the collection name.
Click on Finish.
Ex:
VBWINDOW(“FORM”).ACTIVATE
VBWINDOW(“FORM”).CLICK 250,34
VBWINDOW(“FORM”).VIRTUALBUTTON(“VIRBUTTON”).CLICK
VBWINDOW(“FORM”).CLICK 266,124
VBWINDOW(“FORM”).CLICK 222,54
REGULAR EXPRESSIONS: Whenever the QTP is unable to identify the object, due to regular changes in its properties
values dynamically than to solve that problem one need to replace the corresponding constant value in the object
repository with a suitable regular expression.
NAVIGATION:
Open the object repository.
Select the desired object.
Select the desired property value.
Click on configure the value button.
Replace the constant value with suitable regular expression.
Select the check box Regular Expression.
Click on OK.
Ex:
Record the Flight Faxing order.
Change the Fax Order properties through Object repository.
Set the Fax Order---Text-----Fax Order-------Fax Order.* through configure the value.
Enhance the script as follows:
WINDOW("FLIGHT RESERVATION").ACTIVATE
WINDOW("FLIGHT RESERVATION").WINMENU("MENU").SELECT "FILE;OPEN ORDER..."
WINDOW("FLIGHT RESERVATION").DIALOG("OPEN ORDER").WINCHECKBOX("ORDER NO.").SET "ON"
WINDOW("FLIGHT RESERVATION").DIALOG("OPEN ORDER").WINEDIT("EDIT").SET "5"
WINDOW("FLIGHT RESERVATION").DIALOG("OPEN ORDER").WINBUTTON("OK").CLICK
WINDOW("FLIGHT RESERVATION").WINMENU("MENU").SELECT "FILE;FAX ORDER..."
WINDOW("FLIGHT RESERVATION").DIALOG("FAX ORDER NO. 5").ACTIVEX("MASKEDBOX").TYPE "11111111111"
WINDOW("FLIGHT RESERVATION").DIALOG("FAX ORDER NO. 5").WINBUTTON("SEND").CLICK
WINDOW("FLIGHT RESERVATION").CLOSE
DATA TABLE:
NO. TEXT
1 12
2 6
3 4
4 8
5 14
6 16
INPUT/OUTPUT PARAMETERS: It is a concept provided by the QTP, which is used for passing the values into the
Action and returning the values from the Action.
Ex: CALLING AN ACTION BY PASSING INPUT VALUES AND SPECIFYING THE VARIABLES FOR CAPTURING THE RETURN VALUES:
GO TO----->INSERT----->CALL TO EXISTING ACTION---->SPECIFY THE FILE AND ACTION---------->OK.
RUNACTION "ACTION1 [TEST1]", ONEITERATION,10,20,R1,R2,R3
MSGBOX R1
MSGBOX R2
MSGBOX R3
DYNAMIC HANDLING OF OBJECT REPOSITORIES: This is a concept provided in QTP used for associating and
removing the object repositories during the execution dynamically to do the same QTP has provided a utility object
by name REPOSITORIESCOLLECTION.
Ex:
REPPATH="C:\USERS\SURI\DESKTOP\TSR1.TSR"
REPOSITORIESCOLLECTION.REMOVEALL
REPOSITORIESCOLLECTION.ADD(REPPATH)
VBWINDOW("VBWINDOW").VBEDIT("VBEDIT_1").SET "10"
VBWINDOW("VBWINDOW").VBEDIT("VBEDIT_2").SET "20"
VBWINDOW("VBWINDOW").VBBUTTON("ADD").CLICK
VBWINDOW("VBWINDOW").CLOSE
VAR=REPOSITORIESCOLLECTION.FIND(REPPATH)
MSGBOX VAR
REPOSITORIESCOLLECTION.REMOVE(VAR)
NOTE:
REPOSITORIESCOLLECTION.REMOVEALL: Used to remove the previous repositories from the Test.
REPOSITORIESCOLLECTION.ADD: Used to associate the repository to the Test.
REPOSITORIESCOLLECTION.FIND: Used to find the position of the repository. Before removing we have to find the repository.
REPOSITORIESCOLLECTION.REMOVE: Used to remove the association of the repository from the Test. In order to increase the
performance, if there are more no of repositories to the Test.
AUTOMATION OBJECT MODEL: It is a concept introduced in QTP, which is used for automating the operations on
QTP through scripting.
Ex:
DEVELOP THE FOLLOWING SCRIPT IN NOTEPAD AS .VBS FILE:
DIM QTAPP
DIM QTTEST
SET QTAPP=CREATEOBJECT("QUALIFICATION.APPLICATION")
QTAPP.LAUNCH
QTAPP.VISIBLE=TRUE
QTAPP.OPEN "D:\TEST1",TRUE
SET QTTEST=QTAPP.TEST
QTTEST.RUN
QTTEST.CLOSE
QTAPP.OPEN "D:\TEST2",TRUE
SET QTTEST=QTAPP.TEST
QTTEST.RUN
QTTEST.CLOSE
QTAPP.QUIT
CLASS NAME----------OBJECT-------------METHOD.
Double Click on the .VBS file.
DATABASE CONNECTIONS:
Ex:
DATABASE CONNECTION TO ACCESS:
DIM CON,RS
SET CON=CREATEOBJECT("ADODB.CONNECTION")
SET RS=CREATEOBJECT("ADODB.RECORDSET")
CON.PROVIDER="MICROSOFT.JET.OLEDB 4.0"
CON.OPEN= "D:\DB1.MDB"
DO UNTIL RS.EOF
VBWINDOW("CALCULATOR").VBEDIT("VALUE1").SET RS.FIELDS("V1")
VBWINDOW("CALCULATOR").VBEDIT("VALUE2").SET RS.FIELDS("V2")
VBWINDOW("CALCULATOR").VBBUTTON("ADD").CLICK
RS.MOVENEXT
LOOP
DYNAMIC HANDLING OF FILE SYSTEM: It is a concept provided by QTP used for performing the operations on the file
system dynamically during the execution.
Ex:
DIM FSO,VAR
SET FSO=CREATEOBJECT("SCRIPTING.FILESYSTEMOBJECT")
SET MYFILE=FSO.OPENTEXTFILE("D:\LOGFILE96.TXT",2,TRUE)
VBWINDOW("CALCULATOR").VBEDIT("VALUE1").SET "10"
VBWINDOW("CALCULATOR").VBEDIT("VALUE2").SET "20"
VBWINDOW("CALCULATOR").VBBUTTON("ADD").CLICK
VAR=VBWINDOW("CALCULATOR").VBEDIT("RESULT").GETROPROPERTY("TEXT")
MYFILE.WRITELINE("THE RESULT IS: "& VAR)
MYFILE.CLOSE
DESCRIPTIVE PROGRAMMING: If at all the objects description is described in the program itself, then that is known
as descriptive programming.
NORMAL SCRIPT DEVELOPED THROUGH RECORDING WHEN OBJECTS INFORMATION PRESENT IN THE OBJECT REPOSITORY:
DIALOG("LOGIN").ACTIVATE
DIALOG("LOGIN").WINEDIT("AGENT NAME:").SET "SURI"
DIALOG("LOGIN").WINEDIT("PASSWORD:").SETSECURE "4B6156E1859AA4023F50BCA2E414AAC3732C88D7"
DIALOG("LOGIN").WINBUTTON("OK").CLICK
DIALOG("TEXT:=LOGIN","WIDTH:=320").ACTIVATE
DIALOG("TEXT:=LOGIN","WIDTH:=320").WINEDIT("ATTACHED TEXT:=AGENT NAME:").SET "SURI"
DIALOG("TEXT:=LOGIN","WIDTH:=320").WINEDIT("ATTACHED TEXT:=PASSWORD:").SETSECURE
"4B6156E1859AA4023F50BCA2E414AAC3732C88D7"
DIALOG("TEXT:=LOGIN","WIDTH:=320").WINBUTTON("TEXT:=OK").CLICK
SET LIN=DESCRIPTION.CREATE
LIN("TEXT").VALUE="LOGIN"
LIN("WIDTH").VALUE="320"
SET AN=DESCRIPTION.CREATE
AN("ATTACHED TEXT").VALUE="AGENT NAME:"
SET PW=DESCRIPTION.CREATE
PW("ATTACHED TEXT").VALUE="PASSWORD:"
SET OK=DESCRIPTION.CREATE
OK("TEXT").VALUE="OK"
DIALOG(LIN).ACTIVATE
DIALOG(LIN).WINEDIT(AN).SET "SURI"
DIALOG(LIN).WINEDIT(PW).SETSECURE "4B6156E1859AA4023F50BCA2E414AAC3732C88D7"
DIALOG(LIN).WINBUTTON(OK).CLICK
RD
DYNAMIC DESCRIPTIVE: 3 STYLE:
DEFINING THE OBJECT INFORMATION IN THE LIBRARY FILE. ATTACH THE LIBRARY FILE TO THE REQUIRED TEST, AND DEVELOP
THE SCRIPT AS FOLLOWS:
DIALOG(LIN).ACTIVATE
DIALOG(LIN).WINEDIT(AN).SET "SURI"
DIALOG(LIN).WINEDIT(PW).SETSECURE "4B6156E1859AA4023F50BCA2E414AAC3732C88D7"
DIALOG(LIN).WINBUTTON(OK).CLICK