Beruflich Dokumente
Kultur Dokumente
• HP Quick Test Pro 9.2 is a functional automation and regression testing tool
• QTP provides record and playback of events
• Uses VBScript as the scripting Language
• Provides keyword view and expert view to view test cases.
• Latest versions of QTP is 9.5 (launched in mid Jan 2008)
• Previous version of QTP: 6.5, 8.0, 8.1, 8.2, 9.0, 9.1
• QTP was previously owned by Mercury Interactive®
With introduction of QTP 9.5, Trial version of QTP 9.2 is not available. QTP 9.5 does
not have any huge enhancement and hence most of the features discussed in this article
will still hold
Launching QTP
When you launch QTP for the first time, Add-in manager window is displayed
What is Add-in?
b. .NET
c. Java
d. SAP
e. Siebel
f. Stingray
g. VisualAge
h. Web Services
• QTP does not require any Add-in to work on Standard windows application
• Add-ins can only be loaded when starting QTP
Once the selected Add-ins are loaded, QTP window will show up
Hit the record button to start recording. If you are recording for the first time, the Record
and Run Settings dialog box opens as shown below
What all tabs are shown in above dialog would depend on Add-ins that is loaded. Using
above dialog we can set on what all application should QTP record on.
Note: If QTP does not record anything on your application then make sure you have the
correct settings specified in Record and Run Settings…
Keyword view
The Keyword View enables you to create and view the steps of your test in a keyword-
driven, modular, table format. This is the only view where complete Test flow can be
viewed.
Expert View
In Expert View, QTP displays each operation performed on the application in the form of
a script, comprised of VBScript statements. Complete test flow is not available/visible in
this view.
Object Spy
Object Spy is a tool that can be used to spy Test and run time object for looking at
properties and methods supported by object being spied
Test Object Properties Run-time Object Properties
Object Identification
Object Hierarchy
• QTP only adds those objects from hierarchy which are necessary for it to identify
the object later.
• In this case QTP will add
Browser("Browser").Page("Google").WebEdit("q").set ”Test“
• Copying and pasting code from one script to another script does not work in QTP
as the OR does not get copied to the new script
• There are two types of Object Repositories in QTP
a. Shared OR: Can be used by multiple scripts. A central location to store all
objects
• Default repository
• Specific to actions (Will be used only for a particular action)
• Preferable when application is not dynamic with respect to time
• Cannot be reused
Shared Action repository
Action
Inserting Actions
• Insert Call to New… - Creates a new action and adds a call to the same
• Adds below line to the code
• Insert Call to Existing – User to insert call to a re-usable action located within the
same test or some other test
• This inserts the call to the existing action. In case the action in present in some
other test case then a read only copy of action is inserted
• Insert Call to Copy - Inserts call to an existing re-usable action and creates an
editable copy of that action
• Actions cannot be deleted from a Test from Expert view. To delete a action one
must go to the keyword view and delete the action
• An action call cannot be inserted directly by writing code in Expert View, it has to
be added through the GUI first.
Action Iterations
An action can be run for 1 or more rows from its Local Data Table.
• Similar to Action, a test can also be run for multiple iterations from Global Data
Table
Why Parameterization?
Data Table
• Data Table is excel like spreadsheet which can be user for parameterizing a test
case
• DataTable are of two types
a. Login User
• In below scenario both Global and Local data tables would be used
c. Logout
a. DataTable(”<ColumnName>“, dtGlobalSheet)
b. DataTable(”<ColumnName>“, dtLocalSheet)
• Any changes made to Data table during run-time is stored in run-time data table.
• Run-time data table is available in the test results summary of a test
• DataTable values can be changed at run-time by using below
Environment Variables
• Environment variables are global variables available to all Actions
• They can be used to run a test case on different environment
• To add a new Environment variable go to Test -> Settings…->Environment (Tab)
• Environment variables are of two types
a. Built-in
b. User-Defined
• Built in environment variables give information about the system and the current
test
• User-defined Environment variables added in the Environment tab of Test
Settings are Read-only during the test run
• Environment variables can be added during runtime also using code
Environment.Value(”OrderNumber“) = ”ABCDEF“
• Environment variables can be loaded at run-time from a XML file using the
below code
Environment.LoadFromFile ”C:\TestEnvironment.xml“
<Environment>
<Variable>
<Name>APP_URL</Name>
<Value>http://test1.appserver.com</Value>
</Variable>
</Environment>
Parameters
a. Test parameters
b. Action parameters
Parameter(”<ParamName>“)
Resources
ExecuteFile ”C:\Init.vbs“
• In case of multiple files QTP combines all the files into a single one and executes
the code. The files are combine in bottom to top order
Checkpoints
– Built-in checkpoints
– Custom checkpoints
d. Bitmap checkpoint
e. Accessibility checkpoint
f. Database checkpoint
g. XML Checkpoint
Browser("Google").Page("Google").WebEdit("q").Check CheckPoint("Verify
TextBox_Standard")
Custom Checkpoints
loginExist = Browser().Page().Link(”text:=Login“).Exist(0)
If loginExist then
Else
End if
Test Results
a. Passed
b. Failed
c. Done
d. Warning
e. Information
Descriptive Programming
• Alternate way of writing test cases without having objects in object repository
• Descriptive programming can be done in two ways
Browser(”title:=Google“).Page(”title:=Google“).WebButton(”name:=Search“).Click
• Object Based DP
Browser(brwGoogle).Page(pgGoogle).WebButton(btnSearch).Click
• Description objects can also be used to get all child objects matching a criterion.
Ex –
oDesc(”name”).Value = ”txt_.*“
oDesc(”name”).RegularExpression = True
Msgbox allMatchingObjects.Count
Msgbox allMatchingObjects(0).GetROProperty(”name“)
objStrDesc =
”Browser(”“title:=Test““).Page(”“title:=Test““).Link(”“text:=Login““)“
obj.Click