Unified Functional Testing Tutorial For GUI Testing
Unified Functional Testing Tutorial For GUI Testing
Legal Notices
Warranty
The only warranties for HP products and services are set forth in the express warranty statements accompanying such
products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable
for technical or editorial errors or omissions contained herein.
The information contained herein is subject to change without notice.
Copyright Notice
© Copyright 1992 - 2016 Hewlett-Packard Development Company, L.P.
Trademark Notices
Adobe® and Acrobat® are trademarks of Adobe Systems Incorporated.
Google™ and Google Maps™ are trademarks of Google Inc
Intel® and Pentium® are trademarks of Intel Corporation in the U.S. and other countries.
Microsoft®, Windows®, Windows® XP, and Windows Vista ® are U.S. registered trademarks of Microsoft Corporation.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Documentation Updates
The title page of this document contains the following identifying information:
l Software Version number, which indicates the software version.
l Document Release Date, which changes each time the document is updated.
l Software Release Date, which indicates the release date of this version of the software.
To check for recent updates or to verify that you are using the most recent edition of a document, go to:
https://softwaresupport.hp.com.
This site requires that you register for an HP Passport and sign in. To register for an HP Passport ID, go to
https://softwaresupport.hp.com and click Register.
Support
Visit the HP Software Support Online web site at: https://softwaresupport.hp.com
This web site provides contact information and details about the products, services, and support that HP Software
offers.
HP Software online support provides customer self-solve capabilities. It provides a fast and efficient way to access
interactive technical support tools needed to manage your business. As a valued support customer, you can benefit by
using the support web site to:
l Search for knowledge documents of interest
l Submit and track support cases and enhancement requests
l Download software patches
l Manage support contracts
l Look up HP support contacts
l Review information about available services
l Enter into discussions with other software customers
l Research and register for software training
Most of the support areas require that you register as an HP Passport user and sign in. Many also require a support
contract. To register for an HP Passport ID, go to: https://softwaresupport.hp.com and click Register.
To find more information about access levels, go to: https://softwaresupport.hp.com/web/softwaresupport/access-
levels.
Contents
Welcome to the UFT Tutorial for GUI Testing 6
After completing the tutorial, you can apply the skills you have learned to testing your own application
or Web site.
Note: To learn more about creating and running API tests, see the UFT Tutorial, available from the <
UFT installation folder>\help directory.
Note: This tutorial refers to file system paths that are relevant for Windows 7 operating systems.
The paths in other operating systems may be slightly different.
Note: Unless otherwise specified, references to Application Lifecycle Management or ALM apply
to all currently supported versions of ALM and Quality Center. Note that some features and options
may not be supported in the specific edition of ALM or Quality Center that you are using.
For details, see the HP Unified Functional Testing Product Availability Matrix and the HP Application
Lifecycle Management User Guide or the HP Quality Center User Guide.
Note: It is recommended to work with an soft copy of this tutorial because there are sections in
which you will be asked to copy and paste test steps into UFT. However, keep in mind that in
selected parts of this tutorial, UFT will be recording your operations or learning objects that you
point to with the mouse. During such sessions, you should refrain from switching focus to the PDF
or Help window.
You can open a PDF of this tutorial from your <Unified Functional Testing installation>\help
folder.
You can access the HTML version of this tutorial, by selecting Help > UFT Help > UFT Tutorials >
GUI Testing Tutorial for Web Applications.
Manual testing is time-consuming and tedious, and requires a heavy investment in human resources.
Worst of all, time constraints often make it impossible to manually test every feature thoroughly
before the application is released. This leaves you wondering whether serious bugs have gone
undetected.
Automated GUI testing with UFT addresses these problems by dramatically speeding up the testing
process. You can create tests that check all aspects of your application or Web site, and then run these
tests every time your site or application changes.
As UFT runs tests, it simulates a human user by moving the cursor in a Web page or application window,
clicking GUI objects, and entering keyboard input. However, UFT does all this faster than any human
user.
Reliable Tests perform precisely the same operations each time they are run, thereby eliminating human error.
Repeatable You can test how the Web site or application reacts after repeated execution of the same operations.
Programmable You can program sophisticated tests that bring out hidden information.
Comprehensive You can build a suite of tests that covers every feature in your Web site or application.
Reusable You can reuse tests on different versions of a Web site or application, even if the user interface changes.
Testing Process
The UFT testing process consists of the following main phases:
l What business processes and functionality do you want to test? To answer this, think about
the various activities that customers perform in your application to accomplish specific tasks.
l How can you break your test into small testable units and tasks? You should break the
processes and functionality you want to test into smaller tasks, so that you can create UFT
actions based on those tasks. Smaller and more modular actions make your tests easier to
read and follow, and help ease maintenance in the long run.
At this stage, you can already begin creating test skeletons and adding actions.
2. Preparing the testing infrastructure.
Based on your testing needs, you must determine what resources are required and create these
resources accordingly.
Examples of resources include shared object repositories, which contain test objects that
represent objects in your application, and function libraries, which contain functions that enhance
UFT functionality.
You also need to configure UFT settings so that UFT will perform any additional tasks you may you
need, such as displaying a results report every time you run a test.
3. Building your tests and adding steps to each test.
After the testing infrastructure is ready, you can begin building your tests.
You can create one or more empty tests and add actions to them to create the testing skeletons.
You associate your object repositories with the relevant actions, and associate your function
libraries with the relevant tests, so that you can insert steps using keywords.
You can also add all your tests to a single solution. A solution enables you to store, manage, and
edit any related tests together, without having to close one test before opening another.
You may also need to configure test preferences at this point.
4. Enhancing your test.
l You can test whether your application is functioning correctly by inserting checkpoints into your
tests. Checkpoints search for a specific value of a page, object, or text string.
l You can broaden the scope of your test and test how your application performs the same
operations with multiple sets of data. Do this by replacing fixed values with parameters.
l You can add other sophisticated checks to your test by adding programming and conditional or
loop statements and other programming logic to your test using VBScript.
This tutorial includes steps for checkpoints and parameters only. For additional details about
VBScript statements, see the HP Unified Functional Testing User Guide.
UFT Window
Before you begin creating tests, familiarize yourself with the main UFT window.
The image below shows a UFT window as it would appear right after you create a test, with the test flow
shown in the canvas, and with the toolbar, Solution Explorer, Data pane, and Properties pane displayed:
Take a few minutes to explore the components of the main UFT window. You can then continue to
analyze the application you will be testing in this tutorial, as described in "Analyzing Your Application and
Creating Actions" on page 15.
Document Types
UFT displays open documents in the document pane. Use the document tabs located just below the
toolbar to navigate to open documents and bring them into focus.
l Tests. You can create, view, and modify your test in the Canvas, which enables you to edit the flow of
your test, action, or component.
l Actions or Business Components. Enables you to create, view, and modify your action or business
component, in the following views:
l Keyword View. Contains each step, and displays the object hierarchy, in a modular, icon-based
table.
l Editor. Contains each step as a VBScript line, displayed in a text and code editor. In object-based
steps, the VBScript line defines the object hierarchy.
l Function Library. Enables you to create, view, and modify functions (operations) for use with your
test. Function libraries open as separate tabs in the document pane, similar to tests or actions.
l Application Areas. Enables you to edit the application area settings and resource associations.
l Start Page. Welcomes you to UFT and provides links to recent files, descriptions of new features,
product forums, and other support links. You can use the shortcut buttons to open new and existing
documents.
l Product Movies. Accessible from the Start Page or Help menu, and teaches you about some of the
main UFT features using descriptive and instructional movies.
l Internal Browser Pages. Enables you to open internet pages for forums and other product related
page, such as those accessible from the Start Page or the Help menu.
Panes
Some of the panes and toolbar options listed below are described in detail in subsequent lessons. For
details on other panes and toolbar options, see the HP Unified Functional Testing User Guide.
Solution Displays all the resources associated with your current A tab on the left side of the UFT window.
Explorer test, and enables you to manage these resources.
To display:
Toolbox Displays all the keywords available to your test, and A tab on the left side of the UFT window.
enables you to drag and drop objects, or calls to
To display:
functions, from the Toolbox pane into your test.
l Select View > Toolbox.
toolbar.
Document N/A Displays all open documents. Each document has a tab An unlabeled pane in the center of the
pane that you can click to bring the document into focus. UFT window. Each document tab is
labeled with the document name.
Properties Displays all properties for the currently selected test, A pane on the right side of the UFT
action, component, or application area. window.
To display:
Data Assists you in parameterizing your test. A tab at the bottom of the UFT window.
To display:
Output N/A Displays information sent during the run session. A tab at the bottom of the UFT window.
Errors N/A Displays a list of syntax errors found in your test or A tab at the bottom of the UFT window.
function library.
To display: Select View > Errors.
Provides a list of the resources that are referenced in your
test but cannot be found, such as missing Recovery
Scenarios and missing Function Libraries.
Active N/A Provides a snapshot of your application as it appeared A tab at the bottom of the UFT window.
Screen when you performed a certain step during a recording
To display: Select View > Active
session.
Screen.
Debug Assists you in debugging your test. Tabs at the bottom of the UFT window.
panes Not displayed by default.
The Debug panes include the Breakpoints, Call Stack,
Local Variables, Console, and Watch panes. To display:
Tasks N/A Displays and enables you to manage the tasks defined for A tab at the bottom of the UFT window.
the current test.
To display: Select View > Tasks.
Displays the TODO comment steps of the test's actions or
currently open function libraries.
Search N/A Displays all occurrences of the search criteria you define A tab at the bottom of the UFT window.
Results in the Find dialog box or using other Search menu items.
To display:
Bookmarks N/A Displays the location of bookmarks in your action, A tab at the bottom of the UFT window.
scripted component, or function library, and enables you
To display: Select View > Bookmarks.
to navigate to these bookmarks.
In addition, you can add UFT tools and files that were accessible from the Start menu in previous
versions of Windows to the Start screen, including:
l All UFT tools, such as the Password Encoder and the License Validation Utility
l Non-program files. You can access documentation and the link to the Mercury Tours Website from
the Apps screen.
Note: By default, the Start and Apps screens on Windows 8.x or higher are set to open Internet
Explorer in Metro Mode. However, if User Account Control is turned off on your computer, Windows
8 will not open Internet Explorer in Metro mode. Therefore, if you try to open an HTML shortcut
from the Start or Apps screen, such as the UFT Help or Readme file, an error will be displayed.
To solve this, you can change the default behavior of Internet Explorer so that it never opens in
Metro mode. In the Internet Properties dialog box > Programs tab, select Always in Internet
Explorer on the desktop for the Choose how you open links option. For more details, see
http://support.microsoft.com/kb/2736601 and
http://blogs.msdn.com/b/ie/archive/2012/03/26/launch-options-for-internet-explorer-10-on-
windows-8.aspx.
In this lesson, you will analyze an application to determine what needs to be tested, and you will learn to
create an action in UFT. An action is a logical unit in your test that focuses on testing a particular part of
your application.
For the purpose of this tutorial, you need to become familiar with the Mercury Tours Web site. Mercury
Tours is a sample web application that simulates a web-based flight information and reservation
service. You can access the Mercury Tours Web site using any web browser, but you can perform the
tutorial using only Microsoft Internet Explorer.
As you navigate the site and familiarize yourself with its content, consider the following:
l How is the application organized? Are there separate areas for each activity? What are these
areas? What are these activities? What are the expected outcomes for each activity?
l What screens must be tested in each of these areas? What objects need to be tested in each
screen?
l What activities might be used in multiple scenarios? One example of such an activity is logging on
to the application. Think of these activities as "reusable" parts.
Analyzing your application in terms of its separate parts can help you to design your tests so that
they comprise small, modular units, which are easier to understand, debug, and maintain over time.
l What business processes might users perform using this application? One scenario discussed in
this tutorial is reserving flights. Other scenarios might include making cruise or hotel reservations, or
even registering on the Web site.
l Which development environments need to be supported for testing purposes? UFT provides add-
ins to support many testing environments. You load these add-ins when you open UFT. When working
with this tutorial, you need to load the Web Add-in because Mercury Tours is a Web application. Your
application might require you to load Java or other add-ins.
Note: If you are prompted to have Internet Explorer remember the password, click No.
Note: On the Book a Flight page, you do not have to fill out actual personal or credit card
information; just enter the required information, indicated in red, in the Passengers and Credit
Card sections. You may enter fictitious information.
Creating Tests
Each UFT test includes calls to actions. Actions are units that divide your test into logical sections. When
you create a new test, it contains a call to one action. By dividing your tests into calls to multiple actions,
you can design more modular and efficient tests.
You can also group your tests according to functionality and store them together in solutions. By adding
tests and other documents to solutions, you can open and edit the documents in the same UFT session
without having to open, save, and close each test as you modify it, and you can share resources across
related tests.
Reusable Actions
When you insert a call to a new action, it is reusable by default, enabling you to insert calls to the action
from any test.
When working with reusable actions, you only need to update the existing action stored with the original
test. When you modify the original action, all tests containing calls to the reusable action are updated.
Reusable actions are read-only in the calling test, and you modify them in the test in which they are
stored.
l You have a process that you may need to include in several tests, such as logging in to your
application
l You may have a process that you need to insert several times in the same test, such as filling in user
credential dialog boxes that open whenever a user tries to access a secure part of your application.
If you want to prevent an action from being reused in any test, you can make it non-reusable. Non-
reusable actions are internal actions that can be used only once.
Tip: If you plan to use the same or similar actions in many tests, you might consider creating a
repository test to store your reusable actions. Then you can insert calls to these existing actions
from other tests, linking these actions to the source test. You can store the repository test in the
same solution as your other tests, enabling easier access to your reusable actions.
Copied Actions
You can also insert a copy of an action in your tests if you plan to make changes to the action steps.
This inserts the action as an internal action in the current test. Copies of actions are not linked to the
source test, so that when you insert a call to a copy of an existing action, you can make changes to the
copied action, and your changes will neither affect, nor be affected by, any other test.
The actions you create in this exercise will be reused in subsequent lessons.
1. Start UFT.
Do one of the following:
l If UFT is not currently open:
o Double-click the UFT icon on your desktop or on the Start Screen (in Windows 8.x or
higher)
o In Windows 7, select Start > All Programs > HP Software > HP Unified Functional Testing.
Note: For details on accessing UFT and UFT tools and files in Windows 8.X or higher and
Windows Server 2012, see "Accessing UFT in Windows 8.X or Higher Operating Systems" on
page 14.
In the Add-in Manager, confirm that the Web Add-in is selected, and clear all other add-ins. Click
OK to close the Add-in Manager and open UFT.
The UFT splash screen is displayed while UFT loads your selected add-ins. This may take a few
seconds.
l If UFT is already open: Check which add-ins are loaded by selecting Help > About HP Unified
Functional Testing. The add-ins are listed under Installed Features.
If the Web Add-in is not loaded, you must exit and restart UFT. When the Add-in Manager opens,
select the Web Add-in, and clear all other add-ins.
Note: If the Add-in Manager does not open when starting UFT, select Tools > Options. In
the Startup Options pane of the General tab, select Display Add-in Manager on startup.
When you exit and restart UFT, the Add-in Manager opens.
a. Click the New button . By default, UFT assumes that you want to create a new test, and
the New Test dialog box opens.
b. Select GUI Test, populate the fields as follows:
o Name: Enter MercuryTours.
o Location: Tests are automatically saved at C:\%HOMEPATH%\My Documents\Unified
Functional Testing, and you do not need to modify this path. An example of a default test
location is C:\Documents and Settings\<username>\My Documents\Unified Functional
Testing.
o Solution Name: Enter Tutorial.
c. Select Create directory for solution. The Solution Location value is automatically updated with
your new directory.
d. Click Create. A blank test opens, with the test flow displayed in the canvas, and a blank action
tab opened in the background.
The test name (MercuryTours) and path are displayed in the title bar of the main UFT window.
In the Solution Explorer, you can see that the test is loaded as part of the Tutorial solution.
Note: If the Solution Explorer is hidden, click the Solution Explorer button or select
View > Solution Explorer to display it.
b. In the Name box, enter FlightFinder, and confirm that both Reusable Action and At the end
of the test are selected.
c. Click OK. The dialog box closes and the FlightFinder action is added to the end of your test.
6. Create calls to additional actions.
Add the following actions to your test:
l SelectFlight
l BookFlight
Use the same steps you used in the previous step to create the FlightFinder action.
Your test now contains all of the actions needed to begin this tutorial.
Click Save .
Note: You may have noticed that before you clicked save, an asterisk (*) was displayed in the
MercuryTours document tab and Solution Explorer node. Asterisks are displayed to indicate
that you have unsaved content, and disappear when you save the file. When you save a test,
all test actions are saved too.
l Once the test flow is zoomed in to the maximum, and no longer fits in the canvas, you can also
use the minimap in the bottom left corner of the canvas to navigate through the test flow.
If the minimap is not displayed, click the Minimap button above the canvas to display it.
The minimap can be helpful if you have a test with many actions or nested actions.
You can continue with creating test objects for use in your test, as described in "Creating Object
Repositories" on page 24.
This lesson introduces test objects and run-time objects, and describes how to create shared object
repositories that you can associate with the actions in your test.
An object repository is a storehouse for the test objects (and other object types) used in your test.
Run-Time Objects
During a run session, UFT performs the operations on the run time objects in your application.
Test objects are stored representations of the actual run time objects (or controls) in your application.
UFT creates test objects by learning a select set of the properties and values of the objects in your
application, and uses that data to uniquely identify objects in your application during run time.
Each test object is part of a test object hierarchy. For example, a Link object may be part of a
Browser/Page/Link hierarchy. Top-level objects, such as Browser objects, are known as container
objects, as they can contain lower-level objects, such as Frame or Page objects.
In this lesson, you will use the Object Spy dialog box to view the properties and operations of objects in
your application.
Object Repositories
UFT can store the test objects it learns in the following types of object repository files:
l Shared object repositories. Contain test objects that can be used in multiple actions. This versatility
makes it the preferred repository type for storing and maintaining test objects. By associating a
shared object repository with an action, you make the test objects in that repository available for use
in the action. Any maintenance you perform on an object in a shared object repository is reflected in
all steps (within all actions) using that object.
l Local object repositories. Contain test objects that can be used in one specific action. The objects in
this type of repository cannot be used in any other action. Local object repositories are useful for
backing up your test objects, or for learning new objects.
During a run session, UFT references the test objects stored in the associated object repositories in
order to perform operations on the corresponding run time objects in your application.
When you create an object repository, try to include only the objects you need for testing purposes. This
keeps the object repository relatively small and helps to simplify maintenance and object selection.
Also, make sure that you provide logical names so that others can easily select the correct objects when
creating or modifying tests.
Note: Object repositories can also include checkpoint and output objects. Checkpoint object types
are covered in "Creating Checkpoints and Using Functions" on page 68.
Use the UFT Navigate and Learn option to add objects from the Mercury Tours Web site to a shared
object repository, and then associate the object repository with your test.
e. Click OK. Later, when you run the test or record steps for it, your browser will open to the
Mercury Tours Web site. When the record or run session ends, your browser will close.
3. Open the Mercury Tours Web site.
Open Internet Explorer and browse to the Mercury Tours Web site: http://newtours.demoaut.com.
Ensure that the browser window is maximized.
Note: Be sure to open a new Internet Explorer window after UFT. If you use a browser that was
already open before you opened UFT, UFT may not properly recognize the objects in it.
4. View the properties and operations for some of the objects in the Mercury Tours Web site.
a. In UFT, click the Object Spy toolbar button . The Object Spy dialog box opens.
b. Drag the Object Spy dialog box to the right side of your screen. This enables you to see the
objects you want to spy on more clearly. Verify that the Keep Object Spy on top while spying
toggle button is pressed.
Tip: If you need to switch back and forth between Welcome page, UFT, or any other
window currently open, press CTRL to change the pointing hand back to a regular Windows
pointer. Hold down the CTRL button as long as you need the pointer, and then release it
when you are ready to use the pointing hand.
d. Hover the mouse cursor over the various objects on the page and watch to see what happens
in the Object Spy dialog box.
Note: If UFT does not recognize your objects in the correct location, check to see that you
are viewing the page at 100%, and are not zooming in or out of the page.
For example, if you view the page at 90% or 120%, you may be required to click or select
an area to the left or the right of the actual object in order to recognize it.
e. Position the mouse cursor in the User Name edit box (but do not click it). The test object
hierarchy of that object is displayed. In the hierarchy box, notice that the name of the object is
WebEdit, which is its object class type.
f. Click the User Name edit box. UFT opens again. In the Object hierarchy box, notice that the
object class and name are now selected (WebEdit:userName).
g. Close the Object Spy dialog box.
5. Start the Navigate and Learn process by setting up the Define Object Filter.
In this step, you instruct UFT to learn only the objects that are needed for your test and add them
to the object repository. This helps keep object repository maintenance to a minimum.
a. In UFT, select Resources > Object Repository Manager. The Object Repository Manager
window opens.
b. In the Object Repository Manager window, select Object > Navigate and Learn. Both UFT and
the Object Repository Manager are hidden, and the Navigate and Learn toolbar appears.
Note: The first time you use Navigate and Learn, a message box displaying a tooltip
opens. Click OK to enable the Navigate and Learn toolbar.
c. In the Navigate and Learn toolbar, click the Define Object Filter button . The Define
Object Filter dialog box opens.
d. In the Define Object Filter dialog box, select Selected object types and then click Select. The
Select Object Types dialog box opens.
e. Click Clear All to clear all of the check boxes. Then select the EditBox and Image check boxes
and click OK.
b. In the Navigate and Learn toolbar, click Learn. The Web page flickers and the Adding Objects
message box is displayed as UFT adds representations of the objects on the Web page to a
new object repository.
Note: Adding these objects takes a few seconds. Do not interact with the Web page while
Navigate and Learn runs. Navigate and Learn has finished adding the objects to the object
repository when the flashing stops and the Adding Objects box closes.
Depending on the number of objects in the page, UFT can potentially take a longer time to
learn all the objects.
c. Close the Navigate and Learn toolbar. UFT and the Object Repository Manager window are
visible again.
7. Remove extra objects from the object repository.
In the previous step, UFT added all of the objects that match your filter selection to the object
repository. You only need a few objects for this test, so in this step, you will delete the extraneous
objects.
a. In the Object Repository Manager window, expand the objects in the Test Objects tree. You
should see a list of objects similar to the following:
b. Delete all of the test objects except for Sign-In (image), password (edit box), and userName
(edit box). Select the objects and press Delete. Click Yes in the confirmation box.
Note: You can select multiple objects simultaneously using the SHIFT and CTRL keys.
After you delete the extraneous objects, your tree should resemble the following:
Tip: If you delete Sign-In, password, or userName by mistake, click Undo to restore
the deleted objects.
a. In the Object Repository Manager window, click Save . The Save Shared Object Repository
dialog box opens.
b. Browse to the location in which you want to save your object repositories, such as
C:\%HOMEPATH%\My Documents\Unified Functional Testing\Tutorial. Create a new folder
named Tutorial_ObjectRepositories, and open it. In the File Name box, enter
MercuryToursLogin and click OK.
10. Associate the object repository with the Login action.
Associating an object repository with an action enables you to use any object from that repository
in any step in the associated action.
a. Switch to the UFT window. If the Solution Explorer is not already open, open it by clicking the
Tip: It is recommended to always create a separate shared object repository for each page in your
Web site or each area of your application. This makes it easier to find the correct object when
adding or modifying test steps or when performing maintenance tasks.
For the purposes of this tutorial, you will instruct UFT to learn all of the objects on each page. At this
point, you do not need to associate the object repositories with a specific action.
b. In the Object Repository Manager window, click New . A blank shared object repository
opens.
3. Start the Navigate and Learn process by setting up the Define Object Filter.
a. In the Object Repository Manager window, select Object > Navigate and Learn. Both UFT and
the Object Repository Manager are hidden.
b. In the Navigate and Learn toolbar, click the Define Object Filter button . The Define
Object Filter dialog box opens.
c. In the Define Object Filter dialog box, select All object types and click OK.
Note: Adding these objects takes a few seconds. Do not interact with the Web page while
Navigate and Learn runs.
c. Close the Navigate and Learn toolbar. UFT and the Object Repository Manager window are
visible again.
a. In the Object Repository Manager window, click Save . The Save Shared Object Repository
dialog box opens.
b. If you need to, browse to and open the Tutorial_ObjectRepositories folder. In the File Name
box, enter MercuryToursFlightFinder and click OK.
6. Create a new shared object repository for the Select Flight page.
a. In the Mercury Tours Web site Flight Finder page, click Continue. The Select Flight page opens.
You are now ready to add objects from this page.
b. Switch to the Object Repository Manager window and click New . A blank shared object
repository opens.
c. In the Object Repository Manager window, select Object > Navigate and Learn. Both UFT and
the Object Repository Manager are hidden.
d. In the Mercury Tours Web site Select Flight page, click the Select Flight: Mercury Tours title
tab to bring it into focus as the Web page you want UFT to learn.
e. In the Navigate and Learn toolbar, click Learn. The Web page flickers and the Adding Objects
message box is displayed as UFT begins adding representations of the objects on the Web
page to a new object repository.
Note: Adding these objects takes a few seconds. Do not interact with the Web page while
Navigate and Learn runs.
f. Close the Navigate and Learn toolbar. UFT and the Object Repository Manager window are
visible again.
g. In the Object Repository Manager window, click Save . The Save Shared Object Repository
dialog box opens.
h. If you need to, browse to and open the Tutorial_ObjectRepositories folder. In the File
Name box, enter MercuryToursSelectFlight and click Save.
7. Create object repositories for the remaining Web pages.
a. Using the process described in step 6, create new shared object repositories for each of the
following pages:
o Book a Flight
o Flight Confirmation
b. Name the object repositories MercuryToursBookFlight and
MercuryToursFlightConfirmation, respectively.
8. Associate the MercuryToursFlightFinder.tsr object repository with the FlightFinder action.
a. Switch to the UFT window. If the Solution Explorer is not already open, open it by clicking the
with Action. The Open Shared Object Repository dialog box opens.
c. Click the MercuryToursFlightFinder.tsr shared object repository and click Open.
d. In the dialog box that opens, click Yes
The object repository is now associated with the FlightFinder action, and is displayed in the
Solution Explorer as a child of that action.
9. Associate the remaining object repositories with the relevant actions.
l Associate the SelectFlight action with the MercuryToursSelectFlight.tsr.
Later, when you add steps to each action, all of the required test objects will be available for use.
10. Save your test.
Click Save .
Continue setting up your test infrastructure by adding additional resources to your test, as described in
"Creating Functions and Function Libraries" on page 37.
In "Creating Object Repositories" on page 24, you created shared object repositories and associated
them with the actions in your test. In this lesson, you will create a function and function library, and
associate the function library with your entire test. Associating a function library with a test enables you
to call any of the functions in the function library from that test.
• Introducing Functions 38
• Create a Function 38
• Associate the Function Library with Your Test 40
For example, you may want to create a step that generates a text file and saves it to the file system, or
that accesses data from a Microsoft Excel worksheet.
In this lesson, you will create a function that checks the date format on a page generated by the
Mercury Tours Web site, and then add the function to your test. Begin with "Create a Function" below.
Create a Function
In this exercise, you will create a function that you will later call from your test. This function checks
whether a date is displayed in MM/DD/YYYY format. The function also verifies that the date is
potentially valid, for example, that the month does not exceed 12 or that the date does not exceed 31.
a. Click New down arrow and select New Function Library. The New Function Library
dialog box opens.
Note: If you simply clicked the New button, and not the New button down arrow, the New
Test dialog box opens instead.
b. In the New Function Library dialog box, populate the fields as follows:
o Look in: Browse to the C:\%HOMEPATH%\My Documents\Unified Functional
Testing\Tutorial directory, create a new folder named Tutorial_FunctionLibraries,
and open it to define it as the function library location. (If you copy this path, make sure to
replace <username> with your username.)
o File name: Enter CheckDateFunction.
c. Click Create. The blank function library opens in the document pane.
End If
check_data_validity = True
End Function
Note: If you copy and paste the above code as-is, there will be line breaks splitting up the
commands at the end of the lines starting with reporter. If you try to run this code, the UFT's
compiler will generate an error for each instance of this line break. Therefore, at the end of
each broken line in the code, press Delete to eliminate the break.
4. Click Save .
5. Save the function library.
6. Close the function library.
Select File > Close.
Continue working with your function library, as described in "Associate the Function Library with Your
Test" below.
b. Click the Open button down arrow , and select Open Solution. The Open Solution
dialog box opens.
c. Navigate to the Tutorial.ftsln file, located in C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial, and click Open. (You created the MercuryTours test in "Create a
New Solution, Test, and Actions" on page 19.)
2. Associate the CheckDateFunction.qfl with the MercuryTours test.
a. If the Solution Explorer is not already open, open it by clicking the Solution Explorer button
.
b. In the Solution Explorer, right-click the MercuryTours test node and select Add > Associate
Function Library. The Open Function Library dialog box opens.
c. Locate and open the CheckDateFunction.qfl function library. In the Automatic Relative Path
Conversion dialog box, click Yes. This converts the path to a relative path.
The function library is now associated with the MercuryTours test, and is displayed in the
Solution Explorer as a child of the MercuryTours test node.
Note: Using a relative path keeps the path valid when you move folders containing tests
and other files from one location to another, as long as the folder hierarchy remains the
same.
In this lesson, you will add steps to the actions in your test.
1. Set the relevant Internet Explorer options and close all browsers.
l In Microsoft Internet Explorer, clear the AutoComplete option for all forms, user names, and
passwords (select Tools > Internet Options > Content tab > AutoComplete Settings).
a dummy test, click New , and create a new test using the default values in the
New Test dialog box. You do not need to save this test.
Note: You must have a test or component open in UFT in order to see the Web node in the
Options dialog box.
c. Select Tools > Options > GUI Testing tab > Web > Page/Frame Options node.
d. In the Create a new Page test object for area, select Different URLs or a change in data
transfer and select the first four check boxes. Click OK.
You are now ready to start adding steps to your actions. Begin with "Add Steps to the Login Action"
below.
In this exercise, you will make a reservation for a flight from New York to San Francisco on the Mercury
Tours Web site, adding steps in various ways. After you add steps to the first action, you will analyze the
steps to learn more about the Keyword View.
c. If the Editor is displayed, click the Keyword View button to display the Keyword View.
3. Add the first step to log in to the Mercury Tours Web site.
a. In the Keyword View, in the Item column, click the New Step button. The Item list opens,
displaying the top-level (parent) test object in the associated object repository, and instructing
you to select an item.
In this step, the parent test object is the Welcome: Mercury Tours browser object. Do not
select this browser object because you do not want to perform an operation on the main
browser window. You only need to insert steps on the objects on which you want to perform
operations.
b. Select Object from repository to open the Select Test Object dialog box.
Tip: Quotes are automatically added around the value you entered in the Value column,
indicating that this is a String value. If the method supported an Index value, and you
entered an Index value, no quotes would be added.
f. Select View > Editor to display the Editor, which displays the syntax of the step in VBScript.
Notice that this step is being performed on a WebEdit (edit box) test object, named userName,
and that:
o The test object hierarchy for the WebEdit (edit box) test object is displayed prior to the test
object. In this step the hierarchy includes a Browser object and a Page object.
o The method to be performed on the object is displayed immediately after the test object.
In this step, the method is Set.
o The text to enter in the userName edit box is displayed immediately after the Set method.
The text is displayed in quotes, which indicate that this value is a string. In this step, the
text to enter is tutorial.
o Full stops (periods) separate each part of the step.
b. Select password from the Item list. This time, only one new row is added because the object
shares the same parent objects as the previous step.
In this step:
o The password WebEdit test object is added to the Item cell.
o The default method, Set, is added to the Operation cell. You need to change this method
because the password needs to be encoded.
o Text is added to the Documentation cell indicating that this step clears the text in the edit
box. This is because the step is still missing a required value in the Value cell, and needs to
be updated with the password.
c. Click in the Operation cell to display the down arrow, and then click the down arrow to display
the list of available methods for the selected test object. Select SetSecure from the list. This
method enables the use of encrypted text. Now you need to generate the encrypted text and
insert it in the Value cell.
5. Generate an encoded password using the HP Password Encoder application.
a. Select Start > All Programs > HP Software > HP > Unified Functional Testing > Tools >
Password Encoder or <UFT installation folder>\bin\CryptonApp.exe. The Password
Encoder dialog box opens.
Note: For details on accessing UFT and UFT tools and files in Windows 8.X or higher and
Windows Server 2012, see "Accessing UFT in Windows 8.X or Higher Operating Systems" on
page 14.
The columns in the Keyword View show different information for each step, as follows:
l Item. The item for the step (test object, utility object, function call, or statement) in a hierarchical
icon-based tree.
l Operation. The operation to be performed on the item, for example, Click, Set,or Select.
l Value. The argument values for the selected operation, if required. For example, the text to enter in
an edit box, or the mouse button to use when clicking the image.
l Documentation. Automatically provided documentation of what the step does, in an easy-to-
understand sentence. For example: Click the "Sign-In" image.
l Assignment. The assignment of a value to or from a variable so you can use the value later in the
test. This column is not visible by default.
l Comment. Any textual information you want to add regarding the step, for example, Return to
page used in first step of the test. This column is not visible by default.
Note: You can hide or display individual columns by right-clicking the column heading in the
Keyword View, and selecting a column name from the list.
In the Item column of the Keyword View, you can click the branch arrows to expand or collapse the steps
under each Web page. You can collapse or expand each action by selecting the action name at the top
and then selecting View > Collapse All or View > Expand All.
Take a few minutes to examine the Keyword View in detail, tracing the steps you performed while
creating this action. Then, continue to add additional steps, as described in " Add the Remaining Steps
to Your Test" below.
The table below describes the steps shown in the action in the Keyword View above.
Step Description
For more details on the Keyword View, see the Keyword View chapter in the HP Unified Functional Testing
User Guide.
In this exercise, you will record steps for the FlightFinder action you created for the Flight Finder page.
The steps you add will use test objects from the associated MercuryToursFlightFinder shared object
repository.
Tip: Before you begin a recording session, you may want to place the browser window and this
tutorial window side-by-side on your screen. This allows you to read the tutorial during recording.
b. In the Find a Flight area, enter tutorial in both the User Name and Password boxes and click
Sign-In. The Flight Finder page opens.
c. In UFT, select Record > Record and Run Settings. The Record and Run Settings dialog box
opens.
In the Web tab, select Record and run test on any open browser and click OK. This enables
UFT to record on the open Web page.
d. In UFT, click the Record button . The recording toolbar appears, and UFT begins recording.
The UFT window disappears, and your browser displays the Flight Finder page in the Mercury
Tours Web site.
e. In the Mercury Tours Flight Finder Web page, change the following selections by selecting from
the drop-down lists. (Do not use the calendar option.)
o Departing From: New York
o On: December 29
o Arriving In: San Francisco
Note: If you are performing this tutorial in the month of December, or on the 29th or the
31st of any month, select a different month or date while recording. UFT records an
operation only when you make a change in the application, so this ensures that the step is
recorded. If you accept a default value (or re-select the default value), UFT does not
record an operation.
f. Click CONTINUE to accept the other default selections. The Select Flight page opens.
Click Save .
Do not close the test, because you still want to add steps to other actions. Continue with "Add a Step to
the SelectFlight Action Using the Toolbox Pane" on the next page.
For the purpose of this tutorial, you do not need to make any changes in the Select Flight page, but you
do need to instruct UFT to accept the default options and continue to the next page. Therefore, in this
exercise, you will add one step that instructs UFT to click CONTINUE. You will drag the relevant test
object into your action from the Toolbox Pane, which is another way of creating steps in your action.
Note: Toolbox items are listed according to the action in focus in the document pane. If a test or
function library is in focus, or if you do not have a test open at all, the Toolbox Pane is empty.
b. Click the Open button down arrow , and select Open Solution. The Open Solution
dialog box opens.
c. Navigate to the Tutorial.ftsln file, located in C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial, and click Open. (You created the MercuryTours test in "Create a
New Solution, Test, and Actions" on page 19.)
2. Open the SelectFlight action.
In the Solution Explorer, double-click the SelectFlight action. If the Solution Explorer is not already
b. Locate and drag the reserveFlights Image object into the action, in either the Editor or the
Keyword View. (The reserveFlights Image object should be close to the top of the list of
objects in the Toolbox Pane.)
Note: You may notice that this object repository has many more objects than the
MercuryToursLogin repository. This is because you did not delete extraneous objects in
"Creating Object Repositories" on page 24.
The selected Image test object is added to the step, together with its default method, Click.
o In the Keyword View, the Documentation cell describes what the step does in plain English.
Again, this step is displayed on three rows in the Keyword View because the parent test
objects are part of the step.
o In the Editor, the step is displayed as follows:
In this exercise, you will create steps by copying and pasting content into the Editor, which is another
way of creating steps in your action. The pasted steps do not include values. You will then insert values
for each step using the Keyword View.
Finally, you will use the Step Generator to insert a single step. The Step Generator enables you to define
an entire step in one dialog box, instead of inserting different parts of a step in the various columns of
the Keyword View.
Note: If you copy and paste the above code as-is, there will be line breaks splitting up the
commands at the end of each line. If you try to run this code, the UFT's compiler will
generate an error for each instance of this line break. Therefore, at the end of each line in
the code, press Delete to eliminate the break.
c. In the Value cell for the relevant step in the Keyword View, enter the following:
For: Enter:
For: Enter:
cc_exp_dt_mn Any month from 01 to 12. Make sure that you enter the value as a two-digit number. (This is
the month part of the credit card expiration date.)
cc_exp_dt_yr Any year from 2008 to 2010, as a four-digit number. (This is the year part of the credit card
expiration date.)
Note: Notice that quotation marks are added to the values you enter in the Value column
after you click outside of the cell. These quotes are necessary for the test to run
correctly, and indicate to UFT that the value is a string. If you go back and change a value,
you must add these quotation marks manually, because they are not automatically added
a second time.
5. Add a step using the Step Generator to confirm the booking and return to the Home page.
The last step that you pasted into the BookFlight action clicks SECURE PURCHASE in the Book a
Flight page to complete the transaction. During a run session, this opens the Flight Confirmation
page in the Mercury Tours Web site.
You will now use the Step Generator to define a step to return to the Mercury Tours Welcome
page.
a. Below the last step, click the New Step button. A new row is added to the grid and the drop-
down item list opens in the Item column.
b. In the left margin of the new row, right-click and select Insert Step > Step Generator. The
Step Generator dialog box opens.
d. Click the Select Object button . The Select Test Object dialog box opens. Expand the Flight
Confirmation: Mercury node of the tree.
Note: You may want to collapse the Book a Flight: Mercury node of the tree to view the
Flight Confirmation: Mercury node.
e. Select the home Image object , and click OK. The Step Generator displays the default
options for the home test object.
Define the arguments and values in the Step Generator just as you would in the Keyword View
columns:
o Use the Category and Object drop-down lists to define the value in the Item column in the
Keyword View.
o Use the Operation drop-down lists to define the value in the Operation column. In this step,
the default operation for the home test object, Click, is displayed in the Operation box.
Although you could potentially select a different operation for this test object by clicking
the down arrow, Click is the operation needed for this step.
o Use the Arguments table to define values for the arguments in the Value cell in the
Keyword View. If any of the arguments were mandatory, a red asterisk would be displayed
next to the argument name. In this step, there are no mandatory arguments, and you do
not need to define any values.
o The Step documentation box displays the instruction for this step as it will be displayed in
the Documentation cell of the Keyword View.
o If you want to insert another step after this one, select the Insert another step check box
to open the Step Generator dialog box again after adding this step. In this action, this is the
only step you need in, so there is no need to select this check box.
f. Click OK. The Step Generator closes and the step is added to the Keyword View.
Click Save .
Congratulations! You have created your first test and are ready to run it. Continue with "Running and
Analyzing Tests" on page 63.
When you run your test in this lesson, UFT opens the appropriate application and performs each step in
the test sequentially. When UFT finishes running the test, it displays the results of the run.
• Run a Test 64
• Navigating the Run Results 66
• Analyze the Run Results 66
b. Click the Run button . The Run Test dialog box opens.
c. Click the Options bar to expand the Run Test Options area, and verify that New run results
folder is selected. Accept the default results folder name.
d. Click Run to close the Run dialog box and start running the test.
Watch carefully as UFT opens your browser and starts running the test. In the browser, you can
see UFT perform each step you inserted; a yellow arrow in the left margin of the Keyword View
and the highlighted row indicate the step that UFT is running.
If any errors appear, go to the point in the test that is indicated in the error message, and
verify that the step is configured as described in the relevant task in this tutorial.
When the test run is complete, learn more about the run results, as described in "Navigating the Run
Results" on the next page and "Analyze the Run Results" on the next page.
l Run Results Tree . A graphical representation of the results in an expandable tree, organized
according to the actions and the Web pages visited during the test run. The steps performed during
the run are represented by icons in the tree, which can be expanded (arrow) to view each step. You
can instruct UFT to run a test or action more than once using different sets of data in each run. Each
run is called an iteration, and each iteration is numbered. (The test you ran had only one iteration.)
l Result Details. A high-level results overview report, containing general information about the test,
which steps passed or failed, statistics in pie chart format, and so on.
l Captured Data. If possible, the run results display a still image of the state of your application at a
particular step. This pane is only populated when you select a step from the Run Results tree, and
the selected step has a recorded image.
Your test run succeeded because UFT was able to navigate the Mercury Tours site according to the
steps that you added. If an error occurred and your test did not run successfully, the error will be shown
in the Run Results Viewer. In such cases, go back and make sure that the steps are configured exactly
as described in this tutorial.
Your test is now ready for additional enhancements, including checkpoints. A checkpoint verifies that
expected information is displayed in your application while the test is running. In this lesson, you will
insert checkpoints and use a function to check the validity of the some of the objects in the Mercury
Tours Web site.
Standard Checks values of an object's properties. Check that a radio button is selected.
Checkpoint
Image Checks the property values of an image. Check that the image source file is correct.
Checkpoint (Select the Standard Checkpoint option
and then selecting to check a Web Image
object.)
Table Checks information in a table. Check that the value in a table cell is correct.
Checkpoint (Select the Standard Checkpoint option
and then selecting to check any table
object.)
Page Checks the characteristics of a Web Check how long a Web page takes to load or if a Web page contains
Checkpoint page. broken links.
Text Checks that a text string is displayed in Check whether the expected text string is displayed in the expected
Checkpoint the appropriate place in an application. location in a test object.
Text Area Checks that a text string is displayed Check that an area of a dialog box includes text that was entered in
Checkpoint within a defined area in a Windows- another part of the application.
based application.
Bitmap Checks an area of an application after Check that a Web page (or any portion of it) is displayed as expected.
Checkpoint capturing it as a bitmap.
Database Checks the contents of databases Check that the value in a database query is correct.
Checkpoint accessed by an application or Web site.
Accessibility Identifies areas of a Web site to check for Check if the images on a Web page include ALT properties, required
Checkpoint Section 508 compliance. by the W3C Web Content Accessibility Guidelines.
File Content Checks the text in a document generated Check that the headers in a dynamically-generated PDF file display
Checkpoint or accessed during a run session. the regional corporate headquarters contact information correctly.
XML Checks the data content of XML Check the content of an element to make sure that its tags,
Checkpoint documents. attributes, and values have not changed.
Note: XML file checkpoints are used to check a specified XML file;
XML application checkpoints are used to check an XML document
within a Web page.
You can add most checkpoints to your test either while inserting steps or while recording. The following
sections explain how to create some of the checkpoints described above, in the test you created in "Add
Steps to the Login Action" on page 43.
Note: When UFT creates a checkpoint, it assigns a name based on information inside the
checkpoint—the checked value, for example. The checkpoint name remains unchanged, even if you
subsequently modify the information on which it was based. Keep this in mind when looking for
checkpoints displayed in the Keyword View. Note also, that UFT may shorten the name displayed in
the Keyword View.
For additional details about checkpoints, see the HP Unified Functional Testing User Guide. To add
checkpoints to your test, begin with "Create a Checkpoint Test" below.
Checkpoints do not need to be managed in separate tests, and you are only creating a new test now for
the sake of the tutorial. During your regular working process, you can add checkpoints to any test.
b. Click the Open button down arrow , and select Open Solution. The Open Solution
dialog box opens.
c. Navigate to the Tutorial.ftsln file, located in C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial, and click Open. (You created the MercuryTours test in "Create a
New Solution, Test, and Actions" on page 19.)
2. Save the test as Checkpoint.
a. In the Solution Explorer, select the MercuryTours test node, and then select File > Save As.
b. In the Save Test As dialog box, browse to the C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial directory, and save the test as Checkpoint.
In the Solution Explorer, the MercuryTours test is replaced by the new Checkpoint test. The
MercuryTours test is still saved separately in the file system.
3. Add the MercuryTours test back to the solution.
You can have both the MercuryTours and the Checkpoint tests open at the same time if they are
both referenced from the same solution. This enables you switch back and forth between them if
you want to compare or edit the tests. You can only run a single test at a time.
Note: If you copy this path, make sure to replace <username> with your username.
c. The MercuryTours test appears in the Solution Explorer. Tests are organized in the Solution
Explorer alphabetically.
The solution is saved automatically. Continue with "Check Object Values" below.
Note: The Mercury Tours Web site must be open to the page you want to check before you insert
the checkpoint.
Note: If you are performing this tutorial in the month of December, or on the 29th or the
31st of any month, select a different month or date while recording. UFT records an
operation only when you make a change in the application, so this ensures that the step is
recorded. If you accept a default value (or re-select the default value), UFT does not
record an operation.
c. Click CONTINUE to accept the other default selections. The Select Flight page opens.
d. In the Select Flight page, click CONTINUE to accept the default flight selections. The Book a
Flight page opens.
4. Create a standard checkpoint.
a. If the Editor is displayed, click the Keyword View button to display the Keyword View.
c. Select Design > Checkpoint > Standard Checkpoint. The Checkpoint Properties dialog box
opens.
html tag INPUT INPUT is the html tag as defined in the HTML source code.
innertext In this case, the value of innertext is empty. The checkpoint checks that the value is
empty.
type text text is the type of object as defined in the HTML source code.
value Currently, the value is empty. You need to enter the same value that you specified for
the First Name edit box.
d. In the Name box of the Checkpoint Properties dialog box, enter CheckName as the new
checkpoint name.
e. Scroll down in the object properties area and select the row containing the property named
value. You need to enter the value that matches the value you entered in the actual step. To
do this, click in the Constant box and enter the value you defined as the passenger's first
name, above in "Add Steps to the BookFlight Action Using the Editor and Step Generator" on
page 55.
Note: You can see what you entered by moving the Checkpoint Properties dialog box so
that you can view the Keyword View. The value that you entered is listed in the Value
column of the passFirst0 row, in quotes.
f. In the Insert statement area at the bottom of the Checkpoint Properties dialog box, select
After current step. This inserts the checkpoint after the passFirst0 Set... step. (This is the
step in which the passenger's first name is entered in the First Name box.)
g. Accept the rest of the settings as default and click OK. UFT adds a standard checkpoint step to
your test below the selected step.
Click Save .
You can use this process to insert many checkpoints. Continue to enhance your test by adding a page
checkpoint, as described in "Check Pages" below.
Check Pages
In this exercise, you will add a page checkpoint to the test you created in "Create a Checkpoint Test" on
page 70. The page checkpoint checks that the number of links and images in the page when you run
your test is the same as when UFT learned the objects on which you inserted steps in your test.
b. In the Item column of the Keyword View, locate the Book a Flight: Mercury row. (This is
the row directly above the row displaying passFirst0.)
3. Create a page checkpoint.
a. Right-click the Book a Flight: Mercury row, and select Insert Standard Checkpoint. The Page
Checkpoint Properties dialog box opens.
When you run the test, UFT checks the number of links and images in the page, and the load
time, against those described in the table at the top of the dialog box. The page load time may
vary from computer to computer and your load time results may not match the above image.
UFT also checks the actual target URL of each link and the actual source of each image.
b. In the Name box, enter CheckLinks as the new checkpoint name.
c. Make sure that all three check boxes are selected in the Type column in the table at the top of
the dialog box.
d. Accept the rest of the settings as default and click OK.
UFT adds the page checkpoint to your test. Because this is the first operation on the Book a
Flight: Mercury page, the operation is added directly to the existing Book a Flight: Mercury
page node. It is displayed in the Keyword View as a checkpoint operation on the Book a Flight:
Mercury page.
Click Save .
Continue to enhance your test by adding a table checkpoint, as described in "Check Table Values" below.
b. Click the Open button down arrow , and select Open Solution. The Open Solution
dialog box opens.
c. Navigate to the Tutorial.ftsln file, located in C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial, and click Open. (You created the Checkpoint test in "Create a
Checkpoint Test" on page 70.)
d. In the Solution Explorer, select the Checkpoint test node.
2. Locate the step where you want to add a table checkpoint.
a. If the BookFlight action is not already open, in the Solution Explorer, double-click the
BookFlight action. The action is displayed in the Keyword View.
b. Select the passFirst0 step (the step that enters the passenger's first name into the First
Name edit box).
3. Open the Mercury Tours Web site to the Book A Flight page.
a. If it is not already open, log in to the Mercury Tours Web site: http://newtours.demoaut.com
b. In the User Name and Password boxes, enter tutorial.
c. Click Sign-In. The Flight Finder page opens.
d. Enter flight details.
Change the following selections by selecting from the drop-down lists. (Do not use the
calendar option.)
o Departing From: New York
o On: December 29
o Arriving In: San Francisco
o Returning: December 31
Note: If you are performing this tutorial in the month of December, or on the 29th or
the 31st of any month, select a different month or date while recording. UFT records
an operation only when you make a change in the application, so this ensures that the
step is recorded. If you accept a default value (or re-select the default value), UFT
does not record an operation.
e. Click CONTINUE to accept the other default selections. The Select Flight page opens.
f. In the Select Flight page, click CONTINUE to accept the default flight selections. The Book a
Flight page opens.
4. Configure UFT to record on the open browser page.
a. In UFT, select Record > Record and Run Settings. The Record and Run Settings dialog box
opens.
b. Select Record and run test on any open browser and click OK to close the dialog box.
b. In UFT, click the Record button . UFT begins a recording session and the UFT window is
hidden.
c. Display the UFT window again and expand it if you need to.
d. Select Design > Checkpoint > Standard Checkpoint.The UFT window is hidden, and the pointer
changes into a pointing hand.
Note: If you need to switch back and forth between Welcome page, UFT, or any other
window currently open, press CTRL to change the pointing hand back to a regular Windows
pointer. Hold down the CTRL button as long as you need the pointer, and then release it
when you are ready to use the pointing hand. Using the pointing hand to click objects that
you do not need may cause errors in your test.
e. Click the highlighted string, 270. The Standard Checkpoint dialog box opens, displaying the
object hierarchy.
f. Select the second-to-last item in the hierarchy (WebTable: New York to San Francisco), and
click OK.
The Table Checkpoint Properties dialog box opens, showing the rows and columns of the table.
g. Enter CheckCost as the new checkpoint name in the Name box of the Table Checkpoint
Properties dialog box.
Note that by default, check marks appear in all cells. You can double-click a cell to toggle the
cell selection, or double-click a row or column header to toggle the selection for all the cells in
the selected row or column.
h. Double-click each column header to clear the check marks.
i. Double-click column 3, row 3 to check the value of this cell. (UFT checks only cells containing
check marks.)
j. Scroll through the rows and columns to make sure that only the cell in column 3, row 3 is
checked. If any other cells are checked, double-click them to remove the check.
Tip: You can change the column widths and row heights by dragging the boundaries of the
column and row headers.
Click Save .
In "Check Text Values" below, you will need to navigate to the next page in the Mercury Tours Web
site—the Flight Confirmation page. Therefore, you may want to keep the Mercury Tours Web site
open to the current page.
Continue to enhance your test by adding a text checkpoint, as described in "Check Text Values" below.
c. In the Solution Explorer, select the Checkpoint test node. (You created the Checkpoint test in
"Create a Checkpoint Test" on page 70.)
2. Locate the page where you want to add a text checkpoint.
a. In the Solution Explorer, double-click the BookFlight action. The BookFlight action opens. If it
opens in the Editor click the Keyword View button to display the Keyword View.
Note: If you are performing this tutorial in the month of December, or on the 29th or the
31st of any month, select a different month or date while recording. UFT records an
operation only when you make a change in the application, so this ensures that the step is
recorded. If you accept a default value (or re-select the default value), UFT does not
record an operation.
c. Click CONTINUE to accept the other default selections. The Select Flight page opens.
d. In the Select Flight page, click CONTINUE to accept the default flight selections.
e. In the Book a Flight page, click SECURE PURCHASE. The Flight Confirmation page opens.
4. Configure UFT to record on the open browser page.
a. In UFT, select Record > Record and Run Settings. The Record and Run Settings dialog box
opens.
b. Confirm that Record and run test on any open browser is selected and click OK to close the
dialog box.
5. Create a text checkpoint.
a. In the Flight Confirmation page, under Departing, highlight the text New York (include the
space after it).
b. If you need to, display and expand the UFT window.
c. In the UFT window, click the Record button . UFT begins a recording session, and the
Recording toolbar opens.
d. In the main UFT toolbar, select Design > Checkpoint > Text Checkpoint. The UFT window is
hidden, and the pointer changes into a pointing hand.
Note: If you need to switch back and forth between Welcome page, UFT, or any other
window currently open, press CTRL to change the pointing hand back to a regular Windows
pointer. Hold down the CTRL button as long as you need the pointer, and then release it
when you are ready to use the pointing hand. Using the pointing hand to click objects that
you do not need may cause errors in your test.
e. Click the highlighted text string, New York. The Text Checkpoint Properties dialog box opens.
When Checked Text appears in the list box, the Constant field displays the text string you
highlighted. This is the text UFT looks for when running the test.
f. In the Name box, enter CheckDepartingText as the new checkpoint name.
o Click OK to close the dialog box. San Francisco is removed from the text after part of the
Checkpoint Summary pane.
7. Make sure that the checkpoint is located above the home step.
Drag the new step up a row if needed, to make sure that UFT does not click BACK TO HOME before
performing the checkpoint. In the Keyword View, the step should look as follows:
Click Save .
Learn more about checkpoint management in "Manage Checkpoints in the Object Repository" below,
and then continue with "Run and Analyze a Test with Checkpoints" on the next page.
If applicable, you can even use the same checkpoint in more than one location. For example, if you want
to verify that your organization's logo appears on every page in your application, you can create a
checkpoint and insert it in wherever steps open another page.
For the purposes of this tutorial, you will not be reusing checkpoints.
b. Click the Object Repository button . The Object Repository window opens, displaying a
tree of all test objects and all checkpoint and output objects in the current action.
The tree includes all local objects and all objects in any shared object repositories associated
with the action.
Note: For the purposes of this tutorial, you do not need to modify any object properties. For
details about object properties, see the HP Unified Functional Testing User Guide.
You are ready to run your test. Continue with "Run and Analyze a Test with Checkpoints" below.
b. Select Open the following address when a record or run session begins and click OK to close
the dialog box.
2. Start running your test.
Note: The load time of the page may vary from computer to computer and your results may
not match the image below.
The checkpoint passed because the actual values of the checked properties match the expected
values.
If the checkpoint were to fail ,the run results would display the values of the table cells:
l Cell values that were checked are displayed in black.
The checkpoint passed because the actual value of the checked cell matches the expected value.
In this exercise, you will use the function you created in "Creating Functions and Function Libraries" on
page 37 to check the date format of a Web element in the SelectFlight action.
1. If UFT is not currently open, start UFT and open the Checkpoint test.
a. Open UFT as described in "Create a New Solution, Test, and Actions" on page 19, making sure
that only the Web Add-in is loaded.
b. Click the Open button down arrow , and select Open Solution. The Open Solution
dialog box opens.
c. Navigate to the Tutorial.ftsln file, located in C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial, and click Open. (You created the Checkpoint test in "Create a
Checkpoint Test" on page 70.)
2. Save the test as Function.
a. In the Solution Explorer, select the Checkpoint test node, and select File > Save As.
b. In the Save Test As dialog box, browse to C:\%HOMEPATH%\My Documents\Unified Functional
Testing\Tutorial, and save the test as Function.
In the Solution Explorer, the Checkpoint test is replaced by the new Function test. The
Checkpoint test is still saved separately in the file system.
3. Add the Checkpoint test back to the solution.
You can have the MercuryTours, Checkpoint, and Function test open at the same time, if they are
all referenced from the same solution. This enables you to switch back and forth between them if
you want to compare or edit the tests. You can only run a single test at a time.
a. Click the Add button drop-down arrow , and select Add Existing Test.
b. Navigate to the Checkpoint test, located in C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial, and click Open. (You created the Checkpoint test in "Create a
Checkpoint Test" on page 70.)
Note: If you copy this path, make sure to replace <username> with your username.
c. The Checkpoint test appears in the Solution Explorer. Tests are organized in the Solution
Explorer alphabetically. The solution is saved automatically.
4. Display the Select Flight page in The Mercury Tours Web site.
a. Log in to the Mercury Tours Web site: http://newtours.demoaut.com:
o In the User Name and Password boxes, enter tutorial.
o Click Sign-In. The Flight Finder page opens.
b. Enter flight details.
Change the following selections by selecting from the drop-down lists. (Do not use the
calendar option.)
o Departing From: New York
o On: December 29
o Arriving In: San Francisco
o Returning: December 31
Note: If you are performing this tutorial in the month of December, or on the 29th or the
31st of any month, select a different month or date while recording. UFT records an
operation only when you make a change in the application, so this ensures that the step is
recorded. If you accept a default value (or re-select the default value), UFT does not
record an operation.
c. Click CONTINUE to accept the other default selections. The Select Flight page opens. Notice the
date displayed in the DEPART area. The date is in MM/DD/YYYY format.
b. In the Object Repository Manager, click Open , and browse to and open the
MercuryToursSelectFlight.tsr object repository.
Note: If you need to switch back and forth between Welcome page, UFT, or any other
window currently open, press CTRL to change the pointing hand back to a regular
Windows pointer. Hold down the CTRL button as long as you need the pointer, and then
release it when you are ready to use the pointing hand. Using the pointing hand to click
objects that you do not need may cause errors in your test.
o Click the departure date text string (in the example shown in this task, 12/29/2012). The
Object Selection - Add to Repository dialog box opens.
o Make sure that the WebElement object that represents the departure date you selected
when you entered your flight details is highlighted in the Object Selection dialog box.
o Click OK. The departure date object is added to your repository.
c. After you paste the steps, make sure that the original step still starts on its own line after the
pasted steps. If it does not, place your cursor before the step starts, at Browser("Select a
Flight: Mercury"), and press Enter.
You want the function to run before UFT navigates to the next page in the application.
d. In the first line of the function, modify the date to the date you selected when you entered
your flight details, which will match the departure date object you added to the object
repository.
e. In the PDF version of this tutorial, the first line of the code breaks across two lines. If you are
copying and pasting from the PDF, make sure to remove the line break after 29/: so that the
first line of the code begins with departureDate and ends with ("innertext"). (The Page part
should be displayed as: Page("Select a Flight: Mercury") with a single space between
Flight: and Mercury.)
8. Look at these steps in the Keyword View.
Select View > Keyword to display the Keyword View. (The highlighted step is not part of the
function—it is the step that navigates to the next page in the Mercury Tours Web site.)
For example, you may want to run a test on your Web site using ten separate sets of data. You can
create ten separate tests, each with its own set of data, or you can add ten sets of parameters to a
single test. If you add the parameters, your test will run ten times, each time using a different set of
data.
In this lesson, you will add parameters to your test and run your test with multiple sets of data.
• Parameterizing an Action 97
• Create a Test for Parameterization 97
• Define a Data Table Parameter 98
• Add Parameter Values to a Data Table 101
• Modify Steps Affected by Parameterization 101
• Running and Analyzing a Parameterized Test 104
Note: If the Data pane is not displayed, select View > Data to display it, or click the Data button
.
The Global tab is a data sheet whose data is used for the entire test. If five rows of data are displayed in
the Global data table, the test will run five times (five full iterations). In addition, you can create data
sets for each action, using the relevant action sheet. If you parameterize a step using a Data pane
parameter from a local action sheet and enter five rows of data in that sheet, you can define that
action to run five times within one test iteration.
UFT enables you to insert various types of parameters. This tutorial introduces you to Global Data pane
parameters. For details on other types of parameters, see the HP Unified Functional Testing User Guide.
b. Confirm that the DataTable option is selected from the Parameter drop-down menu. This
means that the value of the parameter will be taken from the UFT Data pane. The Name box is
enabled and displays p_Item. Delete p_Item and enter departure.
c. Click OK to close the dialog box. UFT adds the departure parameter to the Data pane as a new
column and inserts New York in the first row under it.
New York will be the first of several departure cities that UFT will use during test runs of the
application.
Note the change in the step's appearance in the Keyword View. Previously, the step was
displayed as fromPort Select New York. Now, when you click the Value cell, the following
information is displayed, indicating that the value is parameterized using a Data pane
parameter called departure:
b. Click the Open button down arrow , and select Open Solution. The Open Solution
dialog box opens.
c. Navigate to the Tutorial.ftsln file, located in C:\%HOMEPATH%\My Documents\Unified
Functional Testing\Tutorial, and click Open. (You created the Parameter test in "Create a Test
for Parameterization" on page 97.)
d. In the Solution Explorer, select the Parameter test node.
2. Open the FlightFinder action.
In the Solution Explorer, double-click the FlightFinder action.
3. Enter an additional city in the departure column.
In the Data pane, click row 2 in the departure column, enter London and then press Enter. (If the
Data pane is not displayed, select View > Data.)
4. Save the test.
Click Save .
Continue with "Modify Steps Affected by Parameterization" below.
In "Add Parameter Values to a Data Table" on the previous page, you added parameter values for the
departure city in the FlightFinder action. In this exercise, you will modify the text checkpoint so that UFT
checks for the text that matches the current departure city during the test run.
action opens. (If the Editor is displayed, click the Keyword View button to display the
Keyword View.)
b. Right-click the Flight Confirmation: Mercury row with the existing checkpoint and select
Checkpoint Properties.
Note: You may need to expand the Flight Confirmation: Mercury step to see the row with
the checkpoint.
The Text Checkpoint Properties dialog box opens. In the Checked Text area, New York is
displayed in the Constant box. New York is the expected value for the checkpoint for every
iteration.
a. Select Parameter and click the Parameter Options button . The Parameter Options dialog
box opens.
b. In the Name box, select departure. This instructs the checkpoint to use the departure
parameter values in the Data pane for the expected results.
c. Click OK to close the Parameter Options dialog box, and then click OK again to close the Text
Checkpoint Properties dialog box. The checkpoint is now parameterized.
4. Save the test.
In this exercise, you will run the modified Parameter test. UFT will run the test twice, once for a
departure from New York, and a second time for a departure from London. If you go back and add
additional parameters in the Data pane (such as additional departure cities), additional iterations will be
added for each data set, each represented by a row in the data table.
b. Select Open the following address when a record or run session begins and click OK to close
the dialog box.
3. Run the Parameter test.
In "Run a Test" on page 64, you configured UFT to save all images to the run results. Now, you will
configure UFT to save images only when a step fails.
1. Start UFT.
Open UFT as described in "Create a New Solution, Test, and Actions" on page 19. There are no add-
in requirements in this lesson.
2. Modify the global settings for saving images to the run results.
a. Select Tools > Options > GUI Testing tab > Screen Capture node.
b. In the Save still image captures to results option, select For errors. (You can also clear the
Save still image captures to results check box so that no images are ever saved to the run
results. However, this may make troubleshooting your tests more difficult.)
c. Click OK to close the Options dialog box.
l Determine the business processes that users will perform. Plan your tests and actions
accordingly.
l Decide how to organize your test and which operations to include. Consider the goals of the
test, and confirm that your application and UFT are set to match the needs of your test.
At this stage, you can begin creating the skeletal tests and actions to use when testing your
application.
l If you are familiar with testing, it is often most efficient to work with shared object
repositories, which can be used for one or more actions. Object information is kept in one
central location, and when the objects in your application change, you can update them in that
one location for multiple actions, in multiple tests.
Although not discussed in this tutorial, you can also export test objects from a local object
repository to a shared object repository, and you can merge object repositories.
You may also want to create function libraries to enhance UFT functionality.
For details, see the HP Unified Functional Testing User Guide.
3. Build your test.
While you create your test steps (described in "Adding Steps " on page 42), follow the steps you
expect users to perform as they navigate within your application.
4. Enhance your test.
l Add checkpoints (described in "Creating Checkpoints and Using Functions" on page 68) to search
for specific values of a page, object, text string, or table cell.
l Replace fixed values in your test with parameters (described in "Parameterizing Steps and
Objects" on page 96) to check how your application performs the same operations with multiple
sets of data.
You can further enhance your test with programming, conditional, and loop statements, which add
logic to your test. For details, see the HP Unified Functional Testing User Guide.
5. Debug your test.
Debug your test to check that it operates smoothly and without interruption. For details, see the
HP Unified Functional Testing User Guide.
6. Run your test.
Run your test on your application (described in "Running and Analyzing Tests" on page 63) to check
that the application functions as expected.
7. Analyze the run results.
Examine the results of your test to pinpoint defects in your application. (Refer to the appropriate
sections of this tutorial to understand what to look for in the run results for checkpoints or
parameters.)
8. Report defects.
If you have ALM installed, you can submit any defects discovered to an ALM database. (ALM is the
HP solution for test management. For details, see the HP Application Lifecycle Management User
Guide and any other documentation included with ALM.)
Tell us how: [email protected]