rawbacks of Manual Testing
(i) Time consuming.
(ii) More resources required.
(iii)Human Errors
(iv)Repetition of the Task is not much
(v)Tiredness
(vi)Simultaneous auctions are not possible (Parallel)
Test Automation:
Testing Software using any Automation tools is called Test Automation
Advantages of Test Automation:
a) Fast: Tools are faster in execution than human users
b) Reliable: Tools are reliable in complex calculations and tasks
c) Reusable: we can reuse Automated Tests at any number of times
d) Repeatable: we can repeat same operations for required number of times
e) Programmable: we can use flow control statements for applying logic
f) Comprehensive: we can execute test batches without human interaction also
(i) Time consuming.
(ii) More resources required.
(iii)Human Errors
(iv)Repetition of the Task is not much
(v)Tiredness
(vi)Simultaneous auctions are not possible (Parallel)
Test Automation:
Testing Software using any Automation tools is called Test Automation
Advantages of Test Automation:
a) Fast: Tools are faster in execution than human users
b) Reliable: Tools are reliable in complex calculations and tasks
c) Reusable: we can reuse Automated Tests at any number of times
d) Repeatable: we can repeat same operations for required number of times
e) Programmable: we can use flow control statements for applying logic
f) Comprehensive: we can execute test batches without human interaction also
Test
Automation can be used in below areas of Testing:
a)
Functional & Regression Testing
b)
Load/Stress/Performance Testing
c)
Security Testing
d) Unit Testing
Drawbacks of Automation Testing
1)It is expensive
2)We cannot automate all areas.
3)Lack of expatriation.
4)It has some limitations (It cannot test everything)
Drawbacks of Automation Testing
1)It is expensive
2)We cannot automate all areas.
3)Lack of expatriation.
4)It has some limitations (It cannot test everything)
Which Software Testing should not be
automated?
Usability Testing One time testing
Quick look Tests or A.S.A.P (As soon as possible) Testing Ad-hoc testing / Random Testing
Customers requirement are frequently changing.
Quick look Tests or A.S.A.P (As soon as possible) Testing Ad-hoc testing / Random Testing
Customers requirement are frequently changing.
• QTP is an Object Based Testing Tool.
(Object based means; QTP Follows Test Object Model for Performing Testing operations. Based on either Test Objects or Automation Objects or Utility Objects only, we can automate test operations)
(LoadRunner is a Protocol based Test Tool)
• QTP is for Functional and Regression Testing.
(Basically QTP is a Functional and Regression Test tool but we can use it for little bit Compatibility Testing and Performance Testing)
• It follows Keyword Driven Approach.
(Keyword Driven Approach means; Keywords, example: Commands, functions, methods, statements etc.. are used for creating Test scripts)
• It supports Windows Operating Environment only.
(QTP basically depends on User Interface to automate test operations and it is not depends on server side interactions, where as LoadRunner depends on server side Operations, so HP developed LoadRunner for Windows as well as UNIX versions)
• It supports GUI based (Graphical user interface) and Web based Applications Automation, does not support CUI (Command user interface) Applications.
• It has multilingual support. (It supports English, Chinese, Japanese, Korean, etc languages with respect to license.)
• It has adapted Microsoft Visual Basic Scripting edition for programming and Excel like spread sheet for Data driven testing.
Tools support for QTP:
------------------------------
• VB Script for Scripting (for implementing programming logic)
• VB Script engine integrated in QTP, so apart from scripting features we can use File system, Excel, word, Adodb etc. Object models from QTP.
• SQL (Structured query language) engine integrated in QTP, so we can use SQL Statements in QTP to perform Database Operations
• Excel like spread sheet integrated in QTP for performing Data driven Testing
• We can install MS Script Debugger with QTP for Debugging Test scripts.
• QTP uses XML format for Test results, Environment variables and for exporting object repositories.
-------------------------------------------------------
• QTP can be integrated with other Tools like WinRunner and Quality Center.
• QTP can be used for user interface (UI) test case automation and some limited (Non UI) Test case automation like File system operations and Data base operations.
• It was derived from Astra Quick Test (mother tool of QTP).
• It supports IE (Internet Explorer) only for recording tests, for execution it supports other browsers like Mozilla and AOL, opera Etc apart from IE.
• QTP is a Desktop Application (I-Tier/Stand alone).
• QTP developed in .NET Technology.
(Object based means; QTP Follows Test Object Model for Performing Testing operations. Based on either Test Objects or Automation Objects or Utility Objects only, we can automate test operations)
(LoadRunner is a Protocol based Test Tool)
• QTP is for Functional and Regression Testing.
(Basically QTP is a Functional and Regression Test tool but we can use it for little bit Compatibility Testing and Performance Testing)
• It follows Keyword Driven Approach.
(Keyword Driven Approach means; Keywords, example: Commands, functions, methods, statements etc.. are used for creating Test scripts)
• It supports Windows Operating Environment only.
(QTP basically depends on User Interface to automate test operations and it is not depends on server side interactions, where as LoadRunner depends on server side Operations, so HP developed LoadRunner for Windows as well as UNIX versions)
• It supports GUI based (Graphical user interface) and Web based Applications Automation, does not support CUI (Command user interface) Applications.
• It has multilingual support. (It supports English, Chinese, Japanese, Korean, etc languages with respect to license.)
• It has adapted Microsoft Visual Basic Scripting edition for programming and Excel like spread sheet for Data driven testing.
Tools support for QTP:
------------------------------
• VB Script for Scripting (for implementing programming logic)
• VB Script engine integrated in QTP, so apart from scripting features we can use File system, Excel, word, Adodb etc. Object models from QTP.
• SQL (Structured query language) engine integrated in QTP, so we can use SQL Statements in QTP to perform Database Operations
• Excel like spread sheet integrated in QTP for performing Data driven Testing
• We can install MS Script Debugger with QTP for Debugging Test scripts.
• QTP uses XML format for Test results, Environment variables and for exporting object repositories.
-------------------------------------------------------
• QTP can be integrated with other Tools like WinRunner and Quality Center.
• QTP can be used for user interface (UI) test case automation and some limited (Non UI) Test case automation like File system operations and Data base operations.
• It was derived from Astra Quick Test (mother tool of QTP).
• It supports IE (Internet Explorer) only for recording tests, for execution it supports other browsers like Mozilla and AOL, opera Etc apart from IE.
• QTP is a Desktop Application (I-Tier/Stand alone).
• QTP developed in .NET Technology.
•
Since it is Stand-alone Application, It doesn't have Database, It stores
resources as files (Internal and External). We can't share qtp services from
one machine to another, but we can share resources(Ex: Object Repository files,
Function Libraries, Environment
variable files, Recovery scenario files etc...)
File menu:
In this menu have 28 functions.
Edit Menu
In this menu have 31 functions.
Automation Menu:
In this menu have 12 functions.
Resources Menu:
In this menu have 6 functions.
Tools Menu:
In this menu have 11 functions.
7
Stages of QTP Testing Process
1)
Planning
o
Analyzing the AUT (Application Under Test).
o
Automation Test Plan Generation
o
Automation Framework Implementation
o
Generating/Selecting Test cases for Automation
o
Collecting Test Data
o
QTP Tool Settings Configuration
2)
Generating Tests
o
Recording
o
Keyword driven methodology
o
Descriptive Programming
3)
Enhancing Tests
o
Inserting Checkpoints
o
Inserting Output values
o
Adding Comments
o
Synchronization
o
Parameterization
o
Inserting Flow Control Statements
o
Calling User defined functions and/or Reusable Actions
o
Generating Steps though Step Generator
o
Inserting Transaction Points
o
Regular Expressions
4)
Debugging Tests
o
Debug Commands & Break Points
o
Step by step execution
o
Watching Variables
o
Changing values of variables
5)
Running Tests
o
Normal Execution
o
Batch Execution
o
Through AOM Scripting
o
Tests Running through framework
o
Scheduled Execution
6)
Analyzing Results
o
QTP Result window
o
Defining our own Results
o
Exporting Results
o
Deleting Results
7)
Reporting Defects
o
Manual Defect Reporting
o
Tool based Defect Reporting
o
Working with Quality Center
-----------------------------------------------------------
-----------------------------------------------------------
Types
of Statements in QTP Test / Test Script
i) Declarations (Variables and constants)
Dim x, y, z
Const City, Price
ii)
Object calls
Ex1: Dialog("Login").WinEdit("Agent Name:").Set "gcreddy"
Ex2: Browser("Google").Page("Google").Link("Gmail").Click
iii) Comments
iv) Flow Control Statements (Conditional & Loop)
Ex:) If Total=Tickets*Price Then
Msgbox "Test Passed"
Else
Msgbox "Test Failed"
End If
v) Function / Action calls
Ex: Call Login("gcreddy","mercury")
vi) Utility Statements
Ex1: SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
**It launche the Application
Ex2:
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","http://www.icicibank.com/"
vii) VB script other statements
Examples:
Option Explicit
Wait (14)
Disadvantages of Recording
• It
occupies a lot of memory space (due to duplicate objects), So
QTP performance will be reduced
• No
Centralized Maintenance mechanism, So Modifications are very difficult
•
User may not have command on the Recorded script, So locating errors is
difficult
• Recorded
scripts are QTP internal files, they may corrupt.
Advantages of Recording/ Where Applicable
• It
is used for Analyzing the AUT in the initial stage to find out whether the QTP
tool is Recognizing all of our Application Objects or not
• It
is easy to create Tests / Test Scripts
•It
is used for frequently changing UI (User Interface)
• It
takes less time to create Tests
Test Object Model
A test object is an object that
QuickTest creates in the test to represent the actual object in your
application. QuickTest stores information on the object that will help it
identify and check the object during the run session.
--->A run-time object is the actual
object in your application on which methods are performed during the run
session.
--->We
can retrieve or modify property values of the test object during the run
session by adding GetTOProperty and SetTOProperty statements in the Keyword
View or Expert View.
Understanding
Object Repository Types
Objects
can be stored in two types of object repositories—a shared object repository
and a local object repository. A shared object repository stores objects in a
file that can be accessed by multiple tests (in read-only mode).
----->all
objects are automatically saved in a local object repository that can be
accessed by its corresponding action. If you modify an object in the local
object repository, your changes do not have any effect on any other action or
any other test (except tests that call the action, as described in Inserting
Calls to Existing Actions).
----->Local
objects are saved locally with the action, and can be accessed only from that
action. When using a shared object repository, you can use the same object
repository for multiple actions.
Object Identification Types
a) Normal identification
1) Mandatory properties
2) Assistive properties
b) Smart identification
1) base filter properties
2) optional filter properties
c) Ordinal identifier
1) Location
2) index
3) creation time (only for web)
2) index
3) creation time (only for web)
QTP learns information in the following
in case of normal identification:
First of all the qtp learns all the mandatory properties at a time and thinks whether these properties sufficient to identify the object uniquely. if it feels sufficient then it stops learning otherwise,
It learns first assistive property and once again stops and thinks, like this qtp learns one by one. At the end of assistive properties list also if it feels not satisfied and it finally goes to Ordinal Identifier.
QTP learns information in the following in case of Smart Identification:
Smart identification is an optional feature, if we feel normal identification is not sufficient for any object, and then we configure Smart Identification for that object, in order to avoid Ordinal Identifier.
After normal identification if qtp feels not satisfied then it goes to smart identification. in smart identification 2 types of properties available, first qtp learns all base filter properties at a time and thinks whether these properties are sufficient for identifying the object uniquely. If it feels sufficient, then it stops learning otherwise it goes Optional Filter Properties and learns one by one. Still it feels not satisfied finally it goes to Ordinal Identifier.
Ordinal identifiers:
There are 3 types of ordinal identifiers available
First of all the qtp learns all the mandatory properties at a time and thinks whether these properties sufficient to identify the object uniquely. if it feels sufficient then it stops learning otherwise,
It learns first assistive property and once again stops and thinks, like this qtp learns one by one. At the end of assistive properties list also if it feels not satisfied and it finally goes to Ordinal Identifier.
QTP learns information in the following in case of Smart Identification:
Smart identification is an optional feature, if we feel normal identification is not sufficient for any object, and then we configure Smart Identification for that object, in order to avoid Ordinal Identifier.
After normal identification if qtp feels not satisfied then it goes to smart identification. in smart identification 2 types of properties available, first qtp learns all base filter properties at a time and thinks whether these properties are sufficient for identifying the object uniquely. If it feels sufficient, then it stops learning otherwise it goes Optional Filter Properties and learns one by one. Still it feels not satisfied finally it goes to Ordinal Identifier.
Ordinal identifiers:
There are 3 types of ordinal identifiers available
1) Location: is based on object location in the AUT ,location starts from zero.
2) Index: it is based on sequence of
the programs, index starts from zero
3) Creation time: it is based on
loading time of the web objects. qtp generates 0,1,2 like numbers.
Tool Settings Globalization:
As QTP is a I-tier(Stand-alone) application, making Tool settings globally is not possible.
For making tool settings global, QTP is providing a special feature called "Generate Script".
STEPS :
1) Settings available in 3 areas.
a) File->Settings
b) Tools->Options
c) Tools->Object Identification
Tool Settings Globalization:
As QTP is a I-tier(Stand-alone) application, making Tool settings globally is not possible.
For making tool settings global, QTP is providing a special feature called "Generate Script".
STEPS :
1) Settings available in 3 areas.
a) File->Settings
b) Tools->Options
c) Tools->Object Identification
2) Perform required settings and generate Scripts
3) Share Script files to team members and ask them to execute those scripts.
NOTE: After executing these scripts all team members can get same settings.
Checkpoints
Check point is a verification point, it takes expected result
from the user and compares with actual results during execution and provides test
results.
There are 11 Checkpoints available in
QTP:
1. Standard check point
2. Text check point
3. Text area check point
4. Bit map check point
5. Data base
check point
6. Accessibility check point
7. XML Check point (from Application)
8. XML Check point (from Resource)
9. Page check point
10. 11. Table checkpoint
Image checkpoint
Note 1: From 6 to 11 checkpoints are
only for Web.
Note
2: From 9 to 11 checkpoints are hidden checkpoints, we can insert these
checkpoints through standard checkpoint.
1. Standard Checkpoint:
It
checks object property values. We can use this checkpoint for checking any
property value.
Navigation
for Inserting standard checkpoint
Keep
tool under recording mode > place cursor in desired location > Insert
> check point > Standard checkpoint > Show the object > click
okay > select property and enter expected results & click Ok and stop
Recording.
Navigation
for Editing standard checkpoint
Select
Checkpoint statement and right click > choose checkpoint properties option
> modify the value > click Ok.
Navigation
for deleting standard checkpoint:
Select
Checkpoint statements and right click > choose delete option.
Inserting
Standard check points through active screen:
View
> Active Screen >place cursor in desired location >Place mouse pointer
on active screen & right click> choose insert standard checkpoint option
> click ok > enter expected result > click ok
Note:
Inserting Standard check points through keyword view same as in expert view.
Note: We can insert standard checkpoints in 3 ways.
a. Through expert view,
b. Through keyword view,
c. Through Active screen.
2) Text Checkpoint:
It Checks object’s text property
value in different ways.
Navigation:
Keep tool under Recording mode
>Insert menu > checkpoint > Text checkpoint > Show the object >
click ok > Select options
(Match case; ignore spaces, exact match, text not displayed.)
We
can select one or more options > click ok & stop Recording.
3) Text Area Checkpoint:
It checks the text area present in the
application.
Navigation:
Keep tool under Recording mode >
Insert menu> Checkpoint > Text area checkpoint > Mark the area of text
> select one or more options
(Match case; ignore spaces, exact match, text not displayed.)
Click
ok and stop recording.
4. Bitmap checkpoint:
It compares bitmaps; we can compare
complete bitmaps as well as part of the bitmaps.
Navigation:
Keep tool under Recording mode >
Insert menu > Checkpoint > Bitmap checkpoint > show the Bitmap
>click ok >select “check only selected area” option if we want to compare
part of the bitmap > click ok >stop recording.
5. Database checkpoint:
It checks Content of the back end
Database.
Navigation:
Insert > checkpoint > Database
checkpoint >choose “specify SQL
statement manually” option >click next >
click create > select machine data source > Select DSN (QT_flight32) >
click ok > enter SQL statement (select * from orders) > finish > click
ok.
Note: here we do not need to put tool under Recording mode and we do
not need AUT since data is from backend.
6. Accessibility check point:
It checks whether the webpage in our
web application is developed according to W3C (World Wide Web consortium) Rules
and Regulations or not.
It
is a configurable checkpoint, according to our requirements, we can customize.
Configuring
accessibility checkpoint:
Tools
menu> options >web > advanced > check/uncheck items > click
apply > click ok
Invigilation:
Keep
tool under recording mode with web environment
>insert>checkpoint>accessibility checkpoint>show the
webpage>click ok>click ok>stop recording.
Result
Criteria:
a) If item is available but not according to W3C rules then
fail.
b) If an item is available, according to W3C rules then Pass.
c) If an item is not available then result would be pass
7. XML Check point (from Application)
It checks content of the XML file.
Navigation:
Keep tool under Recording mode in web
environment > insert menu > checkpoint (from application)> show the
xml pages >click ok > stop Recording.
8. XML Check point (from Resource)
It checks content of the XML file.
Navigation: Insert menu > checkpoint
>xml checkpoint (from resource) > browse path of the XML File > click ok >
click ok.
Note: 1. If XML file is an individual
and path available, and then we can go for inserting xml checkpoint from
resource.
Note: 2. If XML file is part of web
application, separate path is not available then we can choose inserting XML
checkpoints from application.
9. Page checkpoint:
It checks number of Links, Images and
Loading time in a web page.
It is a hidden checkpoint; we can
insert this through standard checkpoint.
Navigation:
Keep tool under Recording mode with web
environment > Insert menu > checkpoint > Standard checkpoint >show
the web page > click ok > click ok > stop recording.
10. Image
checkpoint:
It checks Image property values.
Navigation:
Keep tool under Recording mode
with web environment > Insert menu > checkpoint >standard checkpoint
> show the image > select image > click ok > click ok >stop
recording.
11. Table
checkpoint:
It checks content of the web tables.
Navigation: Keep tool under Recording
mode under web environment > Insert menu > checkpoint > standard
checkpoint >show the web table > click ok >stop recording.
Parameterization
Passing parameters, through this we can pass multiple values.
Data Driven Testing:
Testing the Same operation with multiple sets of test data.
Types of Parameterization: We can parameterize tests in several ways in QTP
Types of Parameterization: We can parameterize tests in several ways in QTP
1. Through Loop Statements
2. Dynamic Test Data Submission
3. Through Data Table
4. Fetching Test Data directly from External files (Flat files
& Spreadsheets)
5. Fetching Test Data directly from Databases
(MSAcess, Oracle etc).
6. Getting Test Data from front end objects.
1. Through Loop Statements: We can use loop statements for passing sequential numbers & Logical Numbers.
Note: We can’t generate Strings.
For orderno=1 to 10 step 1 ' for one increment step keyword is not
mandatory
Window("Flight Reservation").Activate
Window("Flight
Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open
Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open
Order").WinEdit("Edit").Set orderno
Window("Flight Reservation").Dialog("Open
Order").WinButton("OK").Click
Next
2.Dynamic Test Data Submission: Through Loop Statements we can give strings also but every time user has to enter data.
For x=1 to 3
Agent =inputbox("enter an Agent Name")
Password=inputbox("enter a password")
invokeapplication "C:\Program Files\Mercury
Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set
Agent
Dialog("Login").WinEdit("Agent Name:").Type
micTab
Dialog("Login").WinEdit("Password:").SetSecure
password
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
Next
3. Through Data Table: QTP adds one data table (Spreadsheet) for every test, we can use Data Table for Data Driven Testing.
It has 3 types of usage .
a. Entering test data directly into data table and use
b. Importing test data from external Flat files
c. Importing test data from external Spread sheets
d. Importing test data from Data bases.
A. Entering test data directly into data table and use.
Steps: Generate the basic test>open data table(View>Data
Table)
Click on column header>enter the name of the field (like this
we can create number of columns) > Enter Data>connect the data to test
(variable=datatable(“column name”, Sheet id)
Example: agent=datatable(“agent”,1)
Pass parameters.)
Run the test.
Agent = Datatable("Agent",1)
pwd=Datatable ("Password",1)
invokeapplication "C:\Program Files\Mercury
Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set
Agent
Dialog("Login").WinEdit("Agent Name:").Type
micTab
Dialog("Login").WinEdit("Password:").SetSecure
pwd
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
b. Importing test data from external files:
Open Data Table (view>Data table)>place mouse pointer on data
table and right click>file>import from file>Click ok>Browsw path of
the file(it imports data from the flat file)
Connecting Test Data to QTP Test as above and run the test.
c. Importing test data from external Spread sheets:
Open Data Table (view>Data table)>place mouse pointer on
data table and right click>file>import from file>Click ok>Browse
path of the excel sheet (it imports data from the excel sheet)
Connecting Test Data to QTP Test as above and run the test.
D. Importing test data from Data bases: Through Data table we can
import Test Data from Data bases, but first we have to create /get the DSN(Data
source Name)& we have to use SQL Commands.
1. Creating a Test Database: open MS
Access (or we can use any other database).
Start programs>MS Office>MS Access>file >new>Select
blank Database>enter name of the database>Save with mdb extension.
Creating Tables: Select Create table in
design view>Enter field name(Agent)and Select data type(text)
Like this we can create number of fields>save&enter table name.
Entering Data into Tables: Select table>enter the data.
Creating DSN & importing data
Navigation: view>data table>Place mouse pointer on Data
table>sheet>import>from database(Database query wizard
opens)>choose ‘specify SQL statements manually>click next >click
create>click new>select driver type>click next >browse path to
store> enter DSN Name>Click Save>click next>click
finish>select>browse the database& select>click ok>click
ok>select DSN>click ok>enter SQL statement (select *from
login)>click finish.
Note: DSN Creation is one time activity, by using the DSN we can
get data for number of tests.
4. Fetching Test Data directly from Flat files
Dim fso, myfile
Set fso=createobject("scripting.filesystemobject")
Set myfile=fso.opentextfile("d:\trigun.txt",1)
myfile.skipline
While myfile.atendofline <> true
x=myfile.readline
S=split(x,"@")
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set s(0)
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure S(1)
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Close
Wend
Fetching Test Data directly from Excel Sheets
Fetching Test Data directly from Databases
Option explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider=("microsoft.jet.oledb.4.0")
con.open "C:\Documents and Settings\pooja\My Documents\trigun.mdb"
rs.open "select * from login",con
do until rs.eof=true
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set rs.fields ("agent")
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure rs.fields("password")
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Close
rs.movenext
loop
Synchronization
It is a process of matching the
speeds of both QTP and AUT in order to get proper execution and results.
Where Synchronization is required:
During test execution QTP gives
instructions one by one with same speed, but AUT takes less time for some
operations execution and more time for some operations execution, that time we may not get
proper execution and results. In order to get proper results in between QTP
& AUT synchronization is required.
There are several methods available in
QTP for synchronization.
1. Inserting Wait statements.
2. Inserting Synchronization points.
3. Increasing Tool default
synchronization time.
4. Sync Method (Only for WEB)
5. Exist Property
Inserting Wait Statements:
We can insert wait statements in our
test in order to make QTP to wait until AUT completes current operation.
Syntax: Wait(time in seconds)
Note: If we insert wait statements QTP waits up to maximum time even
though operation is completed.
Inserting Synchronization points:
Place cursor in desired
location>keep tool under recording mode>Insert menu>Synchronization
point >show the object >click ok>select property name &
Value(True)>enter time in Milli seconds>click ok>Stop recording.
Note: if we insert Synchronization points, it does not wait up to
maximum time, after completion of the current operations, it goes to next step
immediately.
Syntax: object hierarchy.waitproperty
“property name”,value,time in milli seconds.
Increasing Tool default synchronization
time:
Navigation: File>settings>run
tab>increase object synchronization time out>apply>ok
Note: If we increase QTP tool default
time that can be applied for all statements in the test, but QTP does not wait
up to maximum time unnecessarily, After completion of one statement execution
it goes to next statement immediately.
Sync Method: (only for WEB)
Waits for the browser to complete
current navigation.
Syntax: Object Hirearchy.Sync
Ex: Browser("Yahoo!
Toolbar").Page("Yahoo! Toolbar").Sync
Selecting an appropriate Method:
1. Suppose in our test one or more
statements only are taking more time for execution then selecting “Inserting
synchronization method” is better.
2. Suppose in our test more statements
are taking more time for execution then selecting “increasing tool time out” .
3. Above two are local features but wait
statement is Vbscript feature, even though some drawbacks are there in using
wait statement, it is better to use wait statement in functions.
Inserting Transaction Points
QTP is providing a Utility object
called Services for measuring transaction time
Suppose, we want to measure how much
time that one test or part of the test is taking for execution/running, we can
measure using these transaction point (Start and End)
Syntax:
Services.StartTransaction “Transaction Name”
Statements
-------
------
Services.EndTransaction “Transaction Name”
Note: these options (Start and End Transactions) available in QTP tool Insert menu
Example:
services.StartTransaction "Login"
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "naga"
Dialog("Login").WinEdit("Password:").SetSecure "4baf50f18b0ae0d5f5425fe760653e96da50bde7"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Activate
services.EndTransaction "Login"
Note: We can insert number of transaction points in a test
Using Timer Function
‘Timer’ is a VB Script Built-in function, that can be used for measuring transaction time.
ST=Timer’ It returns elapsed time since 12:00 AM Mid night in seconds
Example:
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "naga"
Dialog("Login").WinEdit("Password:").SetSecure "4baf50f18b0ae0d5f5425fe760653e96da50bde7"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Activate
ET=Timer
TT=ET-ST
msgbox TT
Note: here ST, ET and TT are variables, you can take any variable, I used:
ST for Start Transaction
ET for End transaction
TT for Transaction Time
Services.StartTransaction “Transaction Name”
Statements
-------
------
Services.EndTransaction “Transaction Name”
Note: these options (Start and End Transactions) available in QTP tool Insert menu
Example:
services.StartTransaction "Login"
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "naga"
Dialog("Login").WinEdit("Password:").SetSecure "4baf50f18b0ae0d5f5425fe760653e96da50bde7"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Activate
services.EndTransaction "Login"
Note: We can insert number of transaction points in a test
Using Timer Function
‘Timer’ is a VB Script Built-in function, that can be used for measuring transaction time.
ST=Timer’ It returns elapsed time since 12:00 AM Mid night in seconds
Example:
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "naga"
Dialog("Login").WinEdit("Password:").SetSecure "4baf50f18b0ae0d5f5425fe760653e96da50bde7"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Activate
ET=Timer
TT=ET-ST
msgbox TT
Note: here ST, ET and TT are variables, you can take any variable, I used:
ST for Start Transaction
ET for End transaction
TT for Transaction Time
Environment Variables
Environment Variables in QTP
These are global variables; if you
want to use some variables globally (From number of tests) declaring as global
variables is better. If we declare as local variables in number of tests,
modifications are difficult.
Types of Environment variables:
1. Built in variables:
These are system defined variables, we can access from all tests but these are
designed as read only.
2. User defined variables:
Variables that we predefine in the active external environment variables file.
We can create as many files as we want and we can change values of variables.
Usage of environment variables:
Syntax:
Variable = Environment(“environment variable name”)
Ex:
X=Environment (“ActionName”)
Msgbox x
Example Script:
ProductDir =environment
("ProductDir")
app=
"\samples\flight\app\flight4a.exe"
Systemutil.Run ProductDir & app
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent
Name:").Set "kajal"
Dialog("Login").WinEdit("Password:").SetSecure
"4b3c86f2107ff565cc195ba6c24739091b656407"
Dialog("Login").WinButton("OK").Click
Creating user defined environment
variables:
Navigation:
File > settings > Environment
> select variable type as user defined > click add icon (+) > enter
variable name & Value > click ok (like this we can create number of
variables) > click export > browse path & enter file name, save with
xml extension > click ok.
Associating environment variable file:
Navigation:
File > settings >Environment >
select variable type as user defined > check “load variables and values from
the external file” > browse path of the xml file > click apply & ok.
Or
We can load environment file
directly
Environment.loadfromfile”path of the
xml file”
Usage of user defined Environment
variables:
Associate environment file to current
test:
Variable = Environment (“Variable
Name”)
X=environment (“city”)
Msgbox x
Modifying Environment files:
Select XML file>open with
notepad>modify the values>Save.
Virtual Object Configuration:
Virtual Object Configuration is a process
of making the QTP to treat a specified area or a user defined object as Virtual
Object.
Virtual objects enable us to create and
run tests on objects that are not normally recognized by QTP.
We can manage the virtual objects
defined on our computer using the Virtual Object Manager.
Navigation:
Ø Select Tools Menu
Ø Go to Virtual objects
Ø Select ‘New Virtual Object’ option
Ø Click Next
Ø Mark the area in the Application with help of mark object
button
Ø Click next
Ø Select one of the following options
o Entire Parent hierarchy
o Parent only
Ø Click on Next
Ø Specify the Desired object name
Ø Specify the Desired collection name
Ø Click finish
Virtual Object Manager:
Virtual object Manager feature enable
us to create and manage Virtual Objects
Status of the Result:
QTP has 4 types of result status
a) Pass
b) Fail
c) Done
d) Warning
Defining our own Result:
Generally QTP provides, test results,
if we use qtp tool features like checkpoints. suppose if we use flow control
statements (conditional and Loop statements), then we have to define our own
result.
For defining our own results, QTP is providing an utility object called "Reporter"
by using reporter, we can define our own results.
Syntax:
Reporter.ReportEvent status of the Result,"Result Step","message"
Example"
Reporter.ReportEvent micPass,"Res","Login operation Successful"
exaplanation:
Reporter- Utility object
ReportEvent-Method
micPass-Status of the Result.
Res-Result step
"Login operation Successful"- Message
Status of the Result:
1) Pass -micPass or 0
2) Fail -micPass or 1
3) Done- micDone or 2
4) Warning- micDone or 3
For defining our own results, QTP is providing an utility object called "Reporter"
by using reporter, we can define our own results.
Syntax:
Reporter.ReportEvent status of the Result,"Result Step","message"
Example"
Reporter.ReportEvent micPass,"Res","Login operation Successful"
exaplanation:
Reporter- Utility object
ReportEvent-Method
micPass-Status of the Result.
Res-Result step
"Login operation Successful"- Message
Status of the Result:
1) Pass -micPass or 0
2) Fail -micPass or 1
3) Done- micDone or 2
4) Warning- micDone or 3
Batch Testing or Batch Execution
Executing a group of Tests or series of tests at a time is known as Batch Testing or Batch Execution. For performing Batch Testing, QTP is providing a separate Tool called Test Batch Runner.
Steps for Batch Testing:
1). Create Individual Tests and Run once.
2). Open 'Test batch Runner' Tool and Form Batches.
3) Provide permission to 'Test batch Runner' to run tests
4). Run or Execute Test Batches from Test Batch Runner.
5) View Test wise Result in 'Test Result Viewer'.
Note: QTP doesn’t provide Batch wise result.
Forming a Test Batch:
Launch Test Batch Runner.
Navigation: Start>program>quicktest professional>Tools>Test Batch Runner>File>new>batch>add>browse path of the test (like this add number of tests)>save with MTB extension (Module test batche)>close test batch runner.
Running or Executing a Test Batch
Open Test Batch Runner Tool
Navigation: File>open>browse path of the test batch>batch>run
Note: Test Batch Runner launches QTP Tool, QTP runs Tests one by one.
Note: Allowing other products to Run Tests.
Navigation: Tools>Options>Run>check allow other mercury products>apply & Ok
Executing partial Test Batch
Open Test Batch Runner >open Test Batch>Select or deselect tests>run test batch.
Recovery Scenario Manager
To recover from unexpected events and
errors that are occurred in the test environment during run session, we can use
Recovery Scenario Manager. For good recovery, error must be known the
occurrence is unknown.
There are (4) Types of events such
as:
(i) Application Crash
An open application fails during Test Run.
Navigation:
Resources Menu -> Recovery Scenario Manager->
Click New- > Click Next - >
Select Application Crash as Trigger
event->Next - >Select selected executable
application->Next ->Select Recovery Operation
[Keyboard, Mouse Operation,
Close Application Process, function Call, Restart, Microsoft Windows] ->Next - >If
you want to check Add another
operation else uncheck->Next - >Next - >Enter
Scenario Name ->Next- >Select Option - >Finish - >Close - >Save the scenario in
specified location with “.qrs”
(qrs stands for QuickTest Recovery
Scenario.)
(ii) Popup Window.
To handle unwanted popups.
Navigation:
Resources Menu ->Recovery Scenario
Manager ->New - >Next - >Select “Popup
Window” as Trigger event ->Next ->Click on Hand Icon - >Show unwanted
window with Hand icon ->Next ->Next - >Select function call as Recovery
Operation ->Next [Open Notepad ->Save empty file with
.vbs extension] - >Browse
the .vbs fie path ->Next ->Uncheck Add another
Recovery Operation - >Next - >
Select Post-Recovery Test Run Option
[Repeat current step and continue, Proceed to
Next step, Proceed to Next Action,
Proceed to next test iteration, Restart current test
run, Stop the Test Run] ->Next ->Enter Scenario Name
->Next - >Select Option - >
Finish ->Save the scenario with
“.qrs” ->Record required Recovery Operation [Click
ok, Click Cancel] take the script
into function ->Save the library file ->Click Run
(iii) Test Run Error.
A step in your test does not run
successfully then Test Run Error
can be raised.
Navigation :
Resources Menu ->Recovery Scenario Manager ->New
- >Next - >Select “Testrunerror
Window” as Trigger event ->Next
->select any error o - >Next - >Next - >Select function call as Recovery
Operation ->Next [Open Notepad ->Save empty file with
.vbs extension] ->Browse
the .vbs fie path ->Next ->Uncheck Add another
Recovery Operation - >Next ->
Select Post-Recovery Test Run Option
[Repeat current step and continue, Proceed to
Next step, Proceed to Next Action,
Proceed to next test iteration, Restart current test
Next run, Stop the Test Run] ��
Select Option �� Next �� Enter Scenario Name �� ��
Save the scenario with Finish �� Record required Recovery Operation [Click “.qrs” ��
ok, Click Cancel] take the script
Click Run Save the library file �� into function ��
(iv) Object State.
The property values of an object in
your application match
specified values. You can specify
property values for each object in the
hierarchy.
Navigation:
Resources Menu -> Recovery
Scenario Manager -> New -> Next -> Select “Object state
Window” as Trigger event -> Next
-> Click on Hand Icon -> Show object with hand icon
-> Next -> Next->select
object property with value (enabled ,false)->click next -> Select
function call as Recovery
Operation -> Next [Open Notepad
-> Save empty file with .vbs extension] -> Browse
the .vbs fie path -> Next ->
Uncheck Add another Recovery Operation -> Next ->
Select Post-Recovery Test Run Option
[Repeat current step and continue, Proceed to
Next step, Proceed to Next Action,
Proceed to next test iteration, Restart current test
run, Stop the Test Run] ->
Next-> Enter Scenario Name -> Next -> Select Option ->
Finish -> Save the scenario with
“.qrs” -> Record required Recovery Operation [Click
ok, Click Cancel] take the script
into function -> Save the library file -> Click Run
Database
connections
Database connection is a facility in computer science that allows client software to communicate with database server software, whether on the same machine or not.
SQL Server
connection strings
SQL ODBC connection strings
Standard Security:
"Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Uid=Your_Username;Pwd=Your_Password;"
Trusted connection:
"Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection=yes;"
SQL OLE DB connection strings
Standard Security:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;"
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL OleDbConnection .NET strings
Standard Security:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;"
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL SqlConnection .NET strings
Standard Security:
1. "Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;" < br>2. "Server=Your_Server_Name;Database=Your_Database_Name;UserID=Your_Username;Password=Your_Password;Trusted_Connection=False"
Trusted connection:
1. "Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
2."Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection=True;"
MS Access connection strings
MS Access ODBC connection strings
Standard Security:
"Driver= {MicrosoftAccessDriver(*.mdb)};DBQ=C:\App1\Your_Database_Name.mdb;Uid=Your_Username;Pwd=Your_Password;"
Workgroup:
"Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\App1\Your_Database_Name.mdb; SystemDB=C:\App1\Your_Database_Name.mdw;"
Exclusive "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\App1\Your_Database_Name.mdb; Exclusive=1; Uid=Your_Username; Pwd=Your_Password;"
MS Access OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to Access database:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; User Id=admin; Password="
Open connection to Access database using Workgroup (System database):
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:System Database=c:\App1\Your_System_Database_Name.mdw"
Open connection to password protected Access database:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:Database Password=Your_Password"
Open connection to Access database located on a network share:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\Server_Name\Share_Name\Share_Path\Your_Database_Name.mdb"
Open connection to Access database located on a remote server:
"Provider=MS Remote; Remote Server=http://Your-Remote-Server-IP; Remote Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb"
MySQL connection strings
MySQL ODBC connection strings
Open connection to local MySQL database using MySQL ODBC 3.51 Driver
"Provider=MSDASQL; DRIVER={MySQL ODBC 3.51Driver}; SERVER= localhost; DATABASE=Your_MySQL_Database; UID= Your_Username; PASSWORD=Your_Password; OPTION=3"
MySQL OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to MySQL database:
"Provider=MySQLProv;Data Source=Your_MySQL_Database;User Id=Your_Username; Password=Your_Password;"
Oracle connection strings
Oracle ODBC connection strings
Open connection to Oracle database using ODBC
"Driver= {Microsoft ODBCforOracle};Server=Your_Oracle_Server.world;Uid=Your_Username;Pwd=Your_Password;"
Oracle OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to Oracle database with standard security:
1. "Provider=MSDAORA;Data Source= Your_Oracle_Database;UserId=Your_Username;Password=Your_Password;"
2. "Provider= OraOLEDB.Oracle;Your_Oracle_Database;UserId=Your_Username;Password=Your_Password;"
Open trusted connection to Oracle database
"Provider= OraOLEDB.Oracle;DataSource=Your_Oracle_Database;OSAuthent=1;"
Validation of text of textbox
in Qtp
I want to validate text of text boxes using Qtp,
if there is a text field for number and i want to validate it so it should strictly accept numeric values in it, like numbers there is lots more fields in web applications form, i want ot validate all fields at a single run of Qtp and from the final result i would come to know that which text fields are accepting wrong values. Different kind of data are passing from the Data table.
Please Help me about this, Thanks in advanced.
if there is a text field for number and i want to validate it so it should strictly accept numeric values in it, like numbers there is lots more fields in web applications form, i want ot validate all fields at a single run of Qtp and from the final result i would come to know that which text fields are accepting wrong values. Different kind of data are passing from the Data table.
Please Help me about this, Thanks in advanced.
Try with the below solution
Once you entered the Data Table value into each text box, call the below sample function; it will check the numeric value is there or not.If the text box contains the non-numeric value it will display the fail message.
Function NumericCheck(ByVal strobject)
abc = strobject.GetROProperty("text")
If IsNumeric (abc) Then
Msgbox "Pass"
else
Msgbox "Fail"
End If
End Function
FunctionCall is mentioned below :
Set strobject = Dialog("dlg_Login").WinEdit("txt_AgentName")
Call NumericCheck(strobject)
Once you entered the Data Table value into each text box, call the below sample function; it will check the numeric value is there or not.If the text box contains the non-numeric value it will display the fail message.
Function NumericCheck(ByVal strobject)
abc = strobject.GetROProperty("text")
If IsNumeric (abc) Then
Msgbox "Pass"
else
Msgbox "Fail"
End If
End Function
FunctionCall is mentioned below :
Set strobject = Dialog("dlg_Login").WinEdit("txt_AgentName")
Call NumericCheck(strobject)
Comments
Post a Comment