Title: Learn HP QTP 10.0 - Part 2
1A Quick Revision of HP QTP 10.0 An Advanced
Solution to Functional Regression Test
Automation Part - 2
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
2Topics Covered in Part - 2
- Recovery Scenarios
- Keyword Driven Testing Framework
- Script Debugging
- Database Management by SQL Queries
- Relative Path
- Regular Expressions
- Working with HP Quality Center
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
3What is a Recovery Scenario?
- Recovery Scenario is a mechanism by which QTP
handles any unexpected windows, pop-ups or
application crashes while the test is running so
that the test is not interrupted. Every type of
recovery situation needs to be handled with a
separate recovery scenario. The recovery
scenarios continuously look for the recovery
situations occurring in the application as long
as the test is running.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
4How to create a recovery scenario?
Select "recovery Scenario Manager" from the
"Resources" menu.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
5How to create a recovery scenario?
Recovery Scenario Wizards starts. Click Next on
this screen.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
6How to create a recovery scenario?
Depending on the desired type of recovery
scenario, select the appropriate Radio button.
Recovery scenarios can be defined for unwanted
Pop-up window, Object state, Test run error or
application crash.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
7How to create a recovery scenario?
Click Next button to view a pop-up window. For
Instance, following Pop-up window may appear
while navigating from non-secure to a secure web
page.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
8How to create a recovery scenario?
QTP captures the window title and window text.
Uncheck the checkbox "Window text contains".
Now QTP look for any security window with the
title Security Information or any generic title.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
9How to create a recovery scenario?
If the window title changes dynamically with some
pattern, Click the checkbox "Regular Expression"
and provide the pattern. Click Next
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
10How to create a recovery scenario?
Next screen informs us that we should define the
recovery operation to be done in order to handle
this window.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
11How to create a recovery scenario?
Click Next button to view the Recovery Operation
window. Select the appropriate action to be
performed.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
12How to create a recovery scenario?
Keyboard or mouse operation allows us to click a
button on the screen. Close application process
allows us to kill the process which starts the
unwanted window so we can continue with
testing. Function call will allow us to write a
user-defined function to handle the unwanted
window. Restart Microsoft Windows allows us to
restart the windows all together if needed. In
above example, click on the first radio button
"Keyboard or mouse operation".
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
13How to create a recovery scenario?
We can show the button we want QTP to click using
the hand icon in the following screen and click
Next button.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
14How to create a recovery scenario?
We can add another recovery scenario if needed
from the following screen. If we don't want
to create another scenario uncheck the checkbox
"Add another recovery operation" Click "Next"
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
15How to create a recovery scenario?
Following screen allows us to define the
Post-recovery operation to be performed.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
16How to create a recovery scenario?
Since the recovery scenario is kicked off only
when the error is about to be thrown since QTP
could not find an object because of the unwanted
window or object state it is logical to
re-execute that particular statement again after
the post-recovery operation. Hence select the
option "Repeat current step and continue". If
the situation is different, make the appropriate
selection depending on the desired operation.
If the exception does not allow us to test the
application anymore in this test run, select the
last radio button "Stop the test run"
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
17How to create a recovery scenario?
Use Proceed to next step if you want to
continue with the test. Use Proceed to next
action if you want to skip the current action in
the flow and continue with the next action. Use
Proceed to next test iteration if you want to
skip the current row of global row and continue
with the next row of Global sheet.Use Restart
current test run if you want to start the test
altogether. Click Next.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
18How to create a recovery scenario?
Provide a name for the recovery scenario and
click "Next".
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
19How to create a recovery scenario?
Make sure that the checkboxes "Add scenario to
current test" and "Add scenario to default test
settings" are selected as shown below. This
will add the Recovery scenario to the current and
the QTP settings as well.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
20How to create a recovery scenario?
Click "Finish" and follow the further steps to
save the recovery scenario to a recovery file
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
21How to create a recovery scenario?
Save the recovery scenario to a recovery file by
Clicking the Save button in the following
screen.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
22How to create a recovery scenario?
Save the file to Disc
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
23Keyword Driven Testing Framework
Keyword-driven testing is a technique that
separates much of the programming work from the
actual test steps so that the test steps can be
developed earlier and can often be maintained
with only minor updates, even when the
application or testing needs change
significantly.The Keyword-driven automation
infrastructure usually includes one or more
shared object repositories and one or more
function libraries. Once the test automation
infrastructure is ready, the application testers
can begin designing their keyword-driven tests by
selecting objects and operation keywords in the
Keyword View.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
24Keyword Driven Testing Framework
The keyword-driven testing methodology divides
test creation into two stages 1) Preparing a
set of testing resources or test automation
infrastructure Preparing the test automation
infrastructure includes a planning stage and an
implementation stage. 2) Creating tests in the
QTP Keyword View by selecting the keywords
(objects and/or operations) that represent the
application functionality we want to test.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
25Keyword Driven Testing Framework
Advantages of keyword-driven testing
methodology Benefit No.1 It enables us to
design our tests at a business level rather than
at the object level. For example, QTP may
recognize a single option selection in our
application as several steps a click on a button
object, a mouse operation on a list object, and
then a keyboard operation on a list sub-item.
We can create an appropriately-named function
to represent all of these lower-level operations
in a single, business-level keyword. Benefit
No. 2 By incorporating technical operations,
like a synchronization statement that waits for
client-server communications to finish, into
higher level keywords, tests are easier to read
and easier for less technical application testers
to maintain when the application changes.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
26Keyword Driven Testing Framework
Advantages of keyword-driven testing
methodology Benefit No. 3 Keyword-driven
testing leads to a more efficient separation
between resource maintenance and test
maintenance. This enables the automation
experts to focus on maintaining objects and
functions while application testers focus on
maintaining the test structure and
design. Benefit No.4 When recording tests, we
may not notice that new objects are being added
to the local object repository. This may result
in many testers maintaining local object
repositories with copies of the same objects.
When using a keyword-driven methodology, you
select the objects for your steps from the
existing object repository.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
27Keyword Driven Testing Framework
Advantages of keyword-driven testing
methodology When you need a new object, you can
add it to your local object repository
temporarily, but you are also aware that you need
to add it to the shared object repository for
future use.Benefit No. 5 When we record a
test, QTP enters the correct object methods, and
argument values for us. Hence it is possible to
create a test with little preparation or
planning. Repercussions Although we can easily
create our tests quickly, But Such tests are
harder to maintain when the application changes
and often require re-recording large parts of the
test.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
28Keyword Driven Testing Framework
Advantages of keyword-driven testing
methodology While using keyword-driven
methodology, we select from existing objects and
operation keywords. Hence we must need to be
familiar with both the object repositories and
the function libraries that are available. We
must also have a good idea of what we want our
test to look like before we begin inserting
steps. This usually results in well-planned and
better-structured tests, which also results in
easier long-term maintenance. Benefit No. 6
Automation experts can add objects and functions
based on detailed product specifications even
before a feature has been added to a product.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
29Keyword Driven Testing Framework
Using Keyword Driven Testing
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
30Keyword Driven Testing Framework
In Keyword Driven Testing Framework every
resource of QTP is considered as a Keyword and
can be dragged and dropped into the script area
from the "Available Keywords" section. For
being successful with this framework the names of
the resources should be clear and relevantly
indicates the function of that particular
resource. For Instance, a function meant for
creating a policy for a customer may be named as
"CreatePolicy".
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
31Keyword Driven Testing Framework
When we expand every folder in the Available
Keywords section, we can view all the resources
or Key words listed out there.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
32Keyword Driven Testing Framework
When we drag and drop the objects from the Object
repository to the script area, the script is
automatically populated for us with the most
common method used for that kind of object. For
Instance Browser("OAKLEAF Acorn - Log in").
Page(" OAKLEAF Acorn"). Frame("mainBody").
WebButton("Add"). Click Browser("OAKLEAF Acorn
-Login").Page("OAKLEAF Acom").Frame(" main
Body").WebEdit("CIientSubGroup").SetWhen we do
the same from the Key Word view it allows us to
set the value for that method.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
33Keyword Driven Testing Framework
Please refer the snapshot.We can set the value
of the Edit field "CommunicationValue" by
clicking in the "Value" field of the Keyword view
for that object after dragging the object and by
clicking "" sign which opens the "Value
Configuration Options" window where we can enter
the value or we can parameterize the value.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
34Keyword Driven Testing Framework
The key to the success of the Key word driven
framework is creating as many functions as
possible for the application and adding all the
objects of the application to the repository
before starting the project. There are two types
of function libraries 1) For application
specific library where we store all the functions
which cover the test casesAnd 2) With generic
functions which includes the functions like
CIoseAllBrowsers(), VerifyObjectEnabled etc.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
35Keyword Driven Testing Framework
Keyword Driven Framework can be further
simplified by using the Keywords or flags from a
data table. For Instance If DataTable("WeightTi
cket",dtGIobaISheet) "Yes" Then RunAction
"WeightTicketVerification WeightTicketVerificatio
n", onelteration End If In this example, the
flag "WeightTicket" in the Global Sheet is set to
"Yes" or "No" and depending on the value of that
flag we run the Action pertaining to that
functionality, in this case the action name is
"WeightTicketVerification".
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
36Keyword Driven Testing Framework
Keyword Driven Frame Work emphasizes that1) All
the functionality is coded in the functions 2)
All these functions are dragged into the script
area This avoids the script outside the
function libraryIt is very important to name
the functions carefully with relevant and
meaningful names. If we have to use multiple
function libraries, we need to ensure that the
names of every function are unique i.e they
should not repeat.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
37Keyword Driven Testing Framework
Use of an Initialization script As a best
practice an Initialization script is used to load
all the required resources into QTP Secondly
this is called in to the Driver script having
flow of actions Such driver script can be
called Flow. The initialization script should
be kept as the first script in the flow of
actions.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
38Script Debugging
Script debugging is a process, involving careful
examination of the code line by line while
executing the script with an objective to see the
actions performed by the script at every step.
This is required to fix a script which does not
perform as expected. Debugging is a process of
eliminating the bugs in QTP scripts. For
starting the debugging process, go to "Debug"
menu and select the desired debug process. We
can start debugging from the existing position of
the cursor or we can execute the script up to the
cursor position in the debug mode.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
39Script Debugging
There are two types of debugging processes 1)
Debugging by "Step Into" When we select "Step
Into" option, we can see if a function being
executed is performing as expected. This will
open the function desired to be debugged in "Read
Only" mode and we can keep on hitting the F11
key on the keyboard to view the execution of
every line of the function. 2) Debugging by
"Step Over This option is selected when we are
sure that the function is performing as expected
we don't want to view the execution of the
function. We can hit "F10" key to execute the
entire function without stopping and will stop
for our next command at the beginning of the next
line after the function call.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
40Script Debugging
We can watch the values of the variables by
adding the variables to the watch list. How to
do?Place the cursor on the variable whose value
needs to be watched while the script is being
executed and from the "Debug" menuSelect "Add
to Watch". This will add the variable to the
Watch list in the debug viewer at the bottom of
the script.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
41Script Debugging
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
42Database Management by SQL Queries
Whenever needed, we can write the SQL queries and
do the insert, delete and update of the records
in the database using QTP scripts. We need the
Data Source Name (DSN) information which can be
created using the Database checkpoint. While
creating the database checkpoint, once the DSN is
created we can view the code for the connection
between QTP the database. We can copy this
code and save this string for use while
connecting directly from the script I.e. without
going through the checkpoint. DSN establishes a
connection between QTP and the database we plan
to work on.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
43Database Management by SQL Queries
We can drive the input to the SQL query using the
data table values. Example of QTP script to
connect to the sample flight VB application's
database provided with QTP and deletes the order
from the Orders table taking the order number
from the "OrderNumber" field in the Global Sheet
of the data table. Set MyConn CreateObject
("ADO DB.Connection") MyConn.ConnectionString
"DBQC\Program Files\HP\QuickTest
Professional\samples\flight\app\flight32.mdb Def
auItDirC\Program Files\HP\QuickTestProfessional\
samples\flight\app DriverMicrosoft Access
Driver (.mdb, .accdb) Driverld281FILMS
Access FILEDSNC\Program Files\Common
Files\ODBC\Data Sources\FlightJuly10DSN.dsn
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
44Database Management by SQL Queries
MaxBufferSize2048MaxScanRows8PageTimeout
5SafeTransactionsOThread s3UIDadminUserCom
mitSyncYes" Set RecordSet CreateObject ("ADO
DB.Recordset") RecordSet.CursorType
1 OrderNumberDataTable("OrderNumber",
dtGIobalSheet) SQLQuery"Delete Orders. Order
Number FROM Orders WHERE Orders.Order Number
"OrderNumer MyConn.Open RecordSet.Open
SQLQuery, MyConn MyConn.Close Set MyConn
Nothing
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
45Relative Path
What is Relative Path? Relative path is a way
of instructing QTP to search for the resources
like Actions, Repositories, Function Libraries
and Data Tables by just specifying the name of
the resource. This is a very useful and
powerful feature of QTP and can save tremendous
amount of operational time when the project has
to be migrated to a different place from the
existing one. This is useful in situation like
For example we had developed all scripts in a
shared drive on the network and the organization
happen to go in for Quality Center and we are
required to migrate all the scripts into Quality
Center.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
46Relative Path
Comparison with Normal Path or Absolute Path In
the normal path or absolute path we go to the
resources tab in the Test Settings and browse the
resources for that script or action. If we have
to change the location of the scripts we have to
open each script and change the pointers to the
resources in the resource tab. This could be
extremely time consuming especially when we
happen to have large number of scripts. The most
complicated situation is of a flow where we have
calls to the reusable actions following the
absolute path, we will be required to build an
entirely new flow to replace the existing one.
Whereas by following the relative path,
changing the resources is a one step process that
could be completed in a few minutes time.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
47How to Implement Relative Path Mechanism
Go to the Options from Tools menu and select
Folders tab. Click on the green "" sign in
the search list section. Browse the folders one
by one where we had stored the actions, function
libraries, data tables, object repositories,
environment variables etc. Now whenever we are
making calls to the resources, we just need to
provide the resource name excluding the path.
QTP will search the search list folders for the
specified resource and find out the desired
resource. When we are to migrate from one
location to the other, we just need to go to the
Folders tab in Options and delete the old
folders and enter the new folders where our
resources are residing now.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
48How to Implement Relative Path Mechanism
Make sure that while using the relative path to
call the resources, we are not duplicating the
action names or repository names etc.
Repercussions of having same name for two
resourcesSame names for the two resources will
be confusing QTP. For example we have two
projects with a shared object repository for each
of them and we have kept the name of the
repository as "SharedObjectRepository" for both
of them. When QTP searches the search folders
specified in the Options Folders it
captures the first instance of the
"SharedObjectRepository" in its path irrespective
of the project. Thus we might end up calling
the wrong shared object repository.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
49How to Implement Relative Path Mechanism
Folders Node to set the relative path.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
50How to Implement Relative Path Mechanism
In QTP 10.0, check the checkbox "Remind me to
use relative paths when specifying a path to
resource" in the Folders node of the options
window.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
51How to Implement Relative Path Mechanism
This will display a pop-up message when someone
uses absolute path for calling the resources and
by clicking "Yes" it is automatically changed to
relative path and the folder is automatically
added to the search folders list.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
52Regular Expressions
When we have an object in our application whose
properties keep changing dynamically based on the
state of the application, we need to manage these
objects with the help of regular
expressions.Regular expressions enable QTP to
identify objects and text strings with varying
values. You can use regular expressions when 1)
Defining the property values of an object in
dialog boxes or in programmatic
descriptions 2) Parameterizing a step 3)
Creating checkpoints with varying values
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
53Regular Expressions
For example, we can use a regular expression to
create a text checkpoint on a date text string,
but the displayed date changes according to the
current date. If we define the date as a
regular expression, the checkpoint checks that
the captured text string matches the expected
date format, rather than checking the exact date
value. What is a regular expressionA regular
expression is a string that specifies a complex
search phrase. By using special characters,
such as a period (.), asterisk (), caret (),
and brackets ( ), we can define the conditions
of a search.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
54Regular Expressions for Property Values
If we expect the value of a property to change in
a predictable way during each run session, we can
use regular expressions when defining or
Parameterizing property values, for example, in
the Object Repository window, or in programmatic
descriptions.For example, our site may include
a form in which the user inputs data and clicks
the Send button to submit the form. When a
required field is not completed, the form is
displayed again for the user to complete. When
resubmitting the form, the user clicks the
Resend button. We can define the value of the
buttons name property as a regular expression,
so that QTP ignores variations in the button name
when clicking the button.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
55Regular Expressions for Check Points
When creating a standard checkpoint to verify the
property values of an object, we can set the
expected value of an objects property as a
regular expression so that an object with a
varying value can be verified. For example,
suppose we want to check that every window and
dialog box in our application contains the name
of your application followed by a hyphen (-) and
a descriptive title. We can add a checkpoint to
each dialog box object in your test to check that
the first part of the title contains the name of
your application followed by a hyphen.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
56Regular Expressions for Check Points
When creating a text checkpoint to check that a
varying text string is displayed on our Web site
or application, we can define the text string as
a regular expression. For example, when booking
a flight in the Mercury Tours sample Web site,
the total cost charged to a credit card number
should not be less than 300. We define the
amount as a regular expression, so that QTP will
ignore variations in the text string as long as
the value is not less than 300.For example,
for table checkpoints we can set cell values as
regular expressions, and for XML checkpoints we
can set attribute or element values as regular
expressions.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
57Regular Expressions - Example
In the following screenshot, the Fax order window
has a title as "Fax Order No. 2" and for the next
order it would have a title of "Fax Order No. 3"
and so on and so forth.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
58Regular Expressions - Example
In the previous example, the window title had
been programmed to get the order number
dynamically from the database and append to the
words "Flight Order No.". Here we need to use a
regular expression on the title property of this
window in the object repository. Open the object
repository and locate this window. Then select
the property (in this case it is
"regexpwndtitle"). A little ltgt sign appears in
that field. Click on that and "Value
Configurations Options" window opens showing the
current value in the constant field.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
59Regular Expressions - Example
Select the checkbox "Regular Expression". In
the constant edit box enter the value "Fax
Order." which indicates that whichever object
has a title of "Fax Order" as the starting words
will be recognized now irrespective of the
numbers following. Here . (dot) represents one
character and (star) represents any number of
characters or numbers.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
60Regular Expressions - Example
Once we click the checkbox "Regular Expression"
we may get a popup asking us whether to add "\"
to the value. Answer that with "No". In QTP
"\" has special meaning which can be like "\t"
for tab, \n" for newline character etc.If we
have to have a "\" in the value we want to pass
as a regular expression, we need to add one more
"\" in front of it so that QTP is instructed not
to consider the "\" as a special character but to
treat it as just a literal.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
61Tips to work with Quality Center
1) Always fill up details tab of the action in
Quality Center when you use the action in a flow.
This will help in maintaining the flows. 2)
When an action is in the development phase keep
the status as in design. As soon as the action
is ready, change the status to Ready. If for some
reason the action needs to be fixed change the
status to "Repair". This will ensure to know
which actions are under development and which
ones are completed.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
62Tips to work with Quality Center
3) Any variables to be created in Quality Center
for better managing the test execution should be
well planned before building the flow. These
variables can be captured into the Initiation
script and can be used for executing the
flow. 4) After flow has been created, include
the details and dependencies of the flow in the
details tab in Quality Center.5) To secure the
usage of the tool, users should be created in
Quality Center with QA Tester privileges for all
the automation engineers. All the users should
be added to the projects on which they are
working.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
63Tips to work with Quality Center
6) The site administration and project
administration users and passwords should be
setup. There should be a main Site
Administrator and a backup Site Administrator.
Easy reach of Site administrator is very
important, as some times the user login does not
get disconnected normally and the test gets
locked, and we need to kill the process from site
admin. 7) Automation engineers should have the
Project Administration privileges instead of
Site Administrator privileges to create any
User Defined variables in QualityCenter.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
64Tips to work with Quality Center
8) In order to better manage the test execution
from Quality Center, create some User Defined
fields in the Test Set and grab those variables
into QTP. For example Start Row, End Row,
TestEnvironment etc. 9) "Test Plan" part of the
Quality Center should be extensively used by
creating the required folders and saving the
corresponding elements in them. For example
The actions folder should have all the reusable
actions for that project/application and Flows
folder should have the Flows saved in them. This
ensures easy accessibility.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
65Tips to work with Quality Center
The following snapshot shows an example of
organizing the folders in Quality Center
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
66Tips to work with Quality Center
10) In order to keep track of the results from
each release, name the test sets with the release
date in it. Provide the dependencies if any in
the Details portion of the Test Set
properties. 11) The tests shoud always be run
through Quality Center. This will enable us to
compare the result history for every release.
12) Since QTP results consume large amount of
disk space on the Quality Center server, it is
better to flush out the results from the test set
from time to time, while preserving the results
of releases during last one year or so.
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt
67Thank You End of Part -2 Quick Revision of HP
QTP 10.0
gtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgtgt www.softwaretestinggenius.
com ltltltltltltltltltltltltltltltltltltltltltlt