Creating Test in Web Application

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

CS-6306 UNIFIED FUNCTIONAL TESTING

Creating Test in Web Application Page|1

Module 010 – Creating Test in Web


Application

“Quality is never an accident; it is always the result of intelligent effort.”


– John Ruskin

Module Objectives:

After completing this module, you should be able to:

 Record and run a test on a web application


 Insert a text checkpoint in a test for a web application

Researching beyond the coverage of this module is highly


encouraged to supplement your understanding of the topics
covered. Always, think and see beyond the box.

The citation provided is a guideline. Please check each citation for


accuracy before use.

So, what are we waiting for? Let us now explore the Unified
Functional Testing 12.0
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|2

GUI Testing Workflow


The process of automating tests for Web applications is similar to
the process of automating tests for Windows-based applications. For Web
applications, a Web browser is used to record and run tests.

Demo Web Application


Before you begin creating tests, you must determine exactly what
you want to test in your application. To do this, you must analyze your
application in terms of its business processes—the distinct activities that
customers perform in your application to complete particular tasks.
For the purpose of this tutorial, you must become familiar with the
Mercury Tours Web site. Mercury Tours is a sample web application that
emulates a web-based flight information and reservation service.
You can access the Mercury Tours Web site using any web browser, but
for the tutorial you must use Microsoft Internet Explorer.
As you navigate the site and familiarize yourself with its content,
consider the following:
 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?

 What screens must be tested in each of these areas? What objects


must be tested in each screen?
 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.
 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.
 Which development environments must 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.
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|3

Exploring the Demo Web Application


Open the Mercury Tours Web site and explore it for a while. As you
navigate the site and familiarize yourself with its content, complete the
following steps:
1. Launch the Mercury Tours Web site. Using Microsoft Internet
Explorer, browse to the Mercury Tours Web site
http://newtours.demoaut.com. The Mercury Tours home page opens.
2. Log in to Mercury Tours. In the Find a Flight area, enter tutorial
in both the User Name and Password boxes and click Sign-In.

Note:
 If you are prompted to have Internet Explorer remember the
password, click No.
 If the username/password combination does not work, you can
register a new username and password in the site. Please enter
training as the username and mercury as the password in that case.
3. Explore the Mercury Tours site. Beginning with the Flight Finder
page, follow the on- screen instructions to get flight information and
reserve a flight. As you navigate the application, think about what
you might want to test, and which pages and objects need to be
included in each test that you might create.
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.
4. End your Mercury Tours session and close the browser:

a.When you finish exploring the Mercury Tours Web site,


click Log Out on the Flight Confirmation page or Sign-Off at the
top of any application page. To sign on again, simply enter
tutorial in the User Name and Password boxes in the SIGN-ON page
or in the Mercury Tours home page.
b.After logging out, close the Internet Explorer window. You
are now ready to use this tutorial to create tests on the
Mercury Tours Web site using UFT.

Enabling the Web Add-in


The Add-in Manager dialog box enables you to select the
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|4

add-ins that you want UFT for GUI Testing to load by selecting the
check boxes adjacent to required add-ins.
Add-ins are important because they help UFT for GUI
Testing operate based on the selected environment. This add-in
concept helps UFT for GUI Testing to support a wide-range of
applications without compromising the performance. And, it
improves object identification reliability.
The list of add-ins that appears in the Add-in Manager
dialog box is dependent on your license. The default add-ins are
Activex, Visual Basic, and web. Additional add-ins require a custom
install of UFT for GUI Testing for the add-ins to appear in the Add-
in Manager. An add-in is loaded if you check it in the Add- in
Manager dialog box.
Example – Select Web if you have to test a web-based
application.
To access:
By default, this dialog box opens when you start UFT for GUI
Testing. To display the Add-in Manager if it does not open when
you start UFT for GUI Testing, select Tools ␣Options ␣ General
tab ␣Startup options node and then select Display Add-in Manager
on startup.
If you select the check box of an add-in that contains a child
add-in, the parent add-in is selected automatically.
If you clear the check box for a parent add-in, the check
boxes for its children are also cleared.

UFT for GUI Testing remembers which add-ins you selected


so that the next time you open UFT for GUI Testing, the same add-
ins are selected in the Add-in Manager dialog box.

Specifying the Record and Run Settings


Before a record session is initiated, you must set the record
and run settings for the Web application that you want to test. To
check/modify the record and run settings:
Click the Record button and the Record & Run Setting dialog
box opens
. or
Select Record ␣Record and Run Settings.
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|5

To configure UFT to open the Mercury Tours Web page,


click the Web tab. Select either of the following options:
Record and run test on any open browser – Enables UFT for
GUI Testing to record a test in Internet Explorer and run the test on
any supported Web browser.
Open the following address when a record or run session
begins – Enables UFT for GUI Testing to automatically open a new
browser session to record and run the test using the specified URL
address.
Note: As a best practice, before you start recording on a
browser, close other browsers and applications and set the record
and run settings.

Playing Back a Web Test


After a test is recorded, run the test to verify the test results.
Run a test on a Web application just as you run a test on a
Windows-based application. The only difference is that you might
need to open a Web browser before playing back a test on a Web
application.

Running a Test
To run a test, perform the following steps:
1. Start UFT and open the MercuryTours test:

a.If UFT is not currently open, open UFT, making sure that
only the Web add-in is loaded.
b.Select File ␣Open ␣Solution. The Open Solution dialog
box opens. Open the appropriate solution file if available or else
create a new GUI test.
2. Configure UFT to save all images to the run results. UFT
allows you to determine when to save images to the run
results.
a.Select Tools ␣Options ␣GUI Testing tab ␣Screen Capture
node.
b.Select the Save still image captures to results check box,
and then select For Errors and
Warnings only from the drop-down menu. c. Click OK to
close the Options dialog box.
3. Start running your test:
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|6

a.In the Solution Explorer, select the Mercury Tours test.


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 the 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 for which you inserted a yellow arrow in the left margin of the
Keyword view and the highlighted row to indicate that 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.

Viewing Web Test Results


When UFT finishes running the test, the Run Results Viewer
opens. Drag the pane borders as needed to clearly view all
populated panes. Initially, the Run Results Viewer displays the
following panes:
 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
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|7

to run a test or action more than one time 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.)
 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.
 Captured Data – 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.

Identifying Web Objects


A Web application uses Web classes and Web objects. A
Web application generally uses a greater variety of objects as
compared to a Windows-based application. Some examples of Web
objects are hyperlinks, images, and frames.
From the UFT menu bar, select Resources ␣Object
Repository to identify the Web objects used in a Web application.

Specifying Timeout for a Web Page


When the Web add-in is loaded, the Test Settings displays a
Web tab. The Browser Navigation Timeout allows 60 seconds for a
page to load by default.
To change the browser timeout settings:
1. From the UFT for GUI Testing menu bar, select File
␣Settings. The Test Settings dialog box is displayed.
2. Click the Web tab.
3. In the Browser Navigation Timeout field, specify the
maximum time in seconds that UFT for GUI Testing should
wait for a Web page to load before it runs a step in the test.

Text Checkpoints for a Web Object


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.
1. Start UFT and open the MercuryTours test:
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|8

a.If UFT is not currently open, make sure that only the Web
Add-in is loaded.
c.Click the Open button down arrow, and select Open
Solution. The Open Solution dialog box opens. Open the
appropriate solution file if available or else create a new GUI test.
2. Save the test as a 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:\Documents and Settings\<username>\My
Documents\UnifiedFunctionalTesting\Tutorial directory, and save
the test as Checkpoint.

Note: <username> is the account settings of the machine


you are working on. c. 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.

Text/Text Area Checkpoint Properties


This dialog box enables you to specify the text to be checked, as
well as specify which text is displayed before and after the checked text.
These configuration options are particularly helpful when the text string
you want to check appears several times or when it could change in a
predictable way during run sessions.
The image above shows an example of the Text Checkpoint
Properties dialog box when adding a text checkpoint during an editing
session. The Text Checkpoint Properties dialog box options differ slightly
during a recording session or when editing an existing checkpoint. The
Text Area Checkpoint Properties dialog box is similar to the Text
Checkpoint Properties dialog box.
To access, ensure that a GUI action or component is in focus in the
document pane. Use one of the following methods:
o Insert a new checkpoint step and select an object or text area from
your application.
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application Page|9

o In the Keyword view, right-click an existing checkpoint step and


select Checkpoint Properties.
o In the local or shared object repository, click an existing checkpoint
object. The Checkpoint details are displayed on the right side of the
Object Repository window, in the Object Details area.
Consider the following when defining the area for a text area checkpoint:
If you parameterize a text string, the captured area must be large
enough to accommodate any string that might replace the one selected
during a run session.
The captured area must be large enough to include all parts of the
required text (Checked Text/Text Before/Text After).Text may change its
position during run sessions. Therefore, make sure that the area you
capture is large enough to allow for acceptable position shifts. If the
defined area is too small, even a slight shift in the text's position causes
the run to fail, although the changed position might be acceptable to you.
If, on the other hand, the position of the text on the screen is critical, or if
you do not want it to exceed certain boundaries, set the defined area
accordingly.
CS-6306 UNIFIED FUNCTIONAL TESTING
Creating Test in Web Application P a g e | 10

eferences and Supplementary Materials


Books and Journals

Micro. Customized Unified Functional Testing 12.0 Essentials Student Guide


Hewlett-Packard Development Company, L.P.
http://hp.com/software/education

You might also like