QTP
Automatic Test Plan Generation
Currently, there is no commercially available tool that can
automatically create a comprehensive test plan, while also supporting test
design and execution.
Test Tool
Fits All
Currently not one single test tool exists that can be used to
support all operating system environments.
1.3
Acquiring
management support
2
Test Tool
Acquisition
3
Automated
Testing Introduction Phase
Test Process Analysis
Test Process
Analysis ensures that an overall test process and strategy are in place and are
modified, if necessary, to allow automated test to be introduced in a
successful fashion. The test engineers
define and collect test process metrics in order to allow for process
improvement. Here test goals, objectives and strategies need to be defined and
test process needs to be documented and communicated to the test team. In this phase, the kinds of testing
applicable for the technical environment will be defined and tests are defined
that can be supported by automated tools.
During the
test process analysis, techniques get defined. Best practices, such as
conducting performance testing during the unit-testing phase are laid out.
Plans for user
involvement are assessed, and test team personnel skills are analyzed against
test requirements and planned test activities. Early test team participation is
emphasized, supporting refinement of requirement specifications into terms,
which can be adequately tested while also supporting test team understanding of
application requirements and design.
Test Tool Consideration
The Test Tool
Consideration phase includes steps that investigate whether incorporation of
automated test tools that have been brought into the company without a specific
project in mind now would be beneficial to a specific project, given the
project testing requirements, available test environment and personnel
resources, the user environment, platform, and product features of the
application under test. Schedule is
reviewed to ensure sufficient time for test tool setup and development of
requirements hierarchy; potential test tools and utilities are mapped to test
requirements; test tool compatibility with the application and environment is
verified; workaround solutions are investigated to incompatibility problems
surfaced during compatibility tests.
4
Test
Planning, Design and Development
Test Planning
Test Design
Test Development
Test Development Architecture
Technical
Environment
5
Execution
and Management of Tests
6
Test Program
Review and Assessment
Summary
For organizations, whose development is performed by relatively small project teams of less than eight people and who are seeking to introduce automated testing as a new practice, the ATLM practice should be tailored to reflect the size, capability and maturity of the project team and the organization. The scope and design of the test effort needs to encapsulate the highest priority test concerns, which might initially only address load performance testing. As the capabilities of the project team develop with the use of an automated testing tool and as the development environment of the organization becomes more mature from a life-cycle perspective, then the project team can expand the scope of the test effort and incorporate additional features of the ATLM.
CHECK POINTS
A checkpoint verifies that
expected information is displayed in a Application while the test is running.
The expected information is captured while creating the check points and is
compared against the data from the Application on runtime
When to go for Check Points in
the test
The Check Points should be used
when the Object in test (Table, Text etc) is static and stationary and the
output can be predicted.
When to Use Different Check
Points
Environments Supported by
Different Check Points
Regular Expressions in Check
Points
Different Coding Alternatives
which can be used instead of Check Points
Output Values
Some Additional Options can be
used with Check Points
Naming
Conventions
Test Name
Actions
Reusable Actions
Variables
Arrays
Temporary Variables
Functions
Function Variables
Coding Standards
Action Template
Coding Techniques
Automated testing does not solve
all of the testing needs. In fact, it usually introduces several new problems.
While many of these problems may be addressed by being extremely disciplined in
an automated testing approach, it is still important to be aware of these
problems.
Many of the available tools have
as a selling point that they make writing automated tests quick and easy. To do
this they rely on simplified scripting languages, which don't allow access to
external resources or publicly developed and supported libraries. The languages
also often limit the extent of abstraction and reuse, or at the least do not
encourage good coding practices for maintainability over the long run. To make
scripting easier, the tools lose the complexity of a full language, so
organizations can only feasibly test the easier problems, missing most of the
unique value of automation. Because of the lack of flexibility, it is common to
see organizations needing several different tools for web testing, desktop GUI testing,
client/server testing, load testing, etc. Now testers have to learn many
simplified scripting languages, so in the long run it may not be so simple to
learn.
For both automated and manual
testing, test cases which document the steps required to pass the business
rules, are the base of any test plan. Because automated scripts are usually
managed separate from the test cases, the automated scripts and the test cases
have a high probability of getting out of sync. Soon, no one knows whether the
test case or the test script represent the current state of the application.
QTP 11 Certification Exam Details:
o
Exam type: Objective (Multiple Choice)
o
Exam Duration: 105 Minutes
o
Number of Questions : 72
o
Pass percentage: 75%
Syllabus
for QTP 11 (HPO- M47) Certification Exam
Detailed
Syllabus
I)
Automated Test Planning
o
Plan
for Test Automation.
o
Plan
for QTP testing.
o
Identify
and describe features and settings.
o
Explain
QTP licensing and packaging.
II)
Creating Basic Tests and Working with Objects
o
Create the basic test.
o
Explain how QTP works with objects.
o
Add steps without recording.
o
Object Identification Configuration and Smart Identification
III)
Test Verification & Enhancements
o
Add
Checkpoints
o
Enhance
tests with parameters.
o
Define
Test results
o
View
test results.
IV)
Modular automated test builds
o
Build Modular Tests using Actions
o
Using
Shared Object Repositories.
V)
QTP and ALM integration
o
Explain the QTP/ALM connection.
o
Define ALM management of QTP resources.
o
Explain
versioning features in QTP
VI)
Automated test troubleshooting
o
Troubleshoot Object Recognition problems.
o
Use Recovery scenarios.
o
Use the Debugging Tool.
o
Measure System Performance.
o
Configure
log tracking
VII)
Advanced QTP Scripting
o
Import and export Excel sheets.
o
Get and set object properties.
o
Using Programmatic Descriptions to bypass repository.
VIII)
Expert View
o
Features of Expert View
o
Describe dynamic object programming.
o
Identify
and describe VBScript elements.
IX)
Web applications
o
Recognize Web Add-in Extensibility.
o
Describe Web event recording use and configuration.
o
Identify
new web testing capabilities.
------------------------------------------------------------
Note: Maximum Questions on QTP Tool features only, Less
/ no importance for Scripting logic (VB Script). Industry point of view and
Product Understanding point view Certification is useful, but work point
limited use only.
In
order to get certification -
o
Explore all Tool Menus and remember QTP commands and Shortcut keys
o
Read HP QTP Documentation
o
Collect Exam papers dumps and Practice
o
Practice Tool features
------------------------------------------------------------------
Recommendations
for using Recovery Scenarios
1
2
3
4
5
6
7
8
Different Post-Recovery Test Run Options:
Actions
Types of Actions
Internal Actions
External Actions
Independent Actions
Nested Actions
Reusable Actions
Non-Reusable Actions
Properties
Copy of Actions
Call to Actions
Split Actions
Action Parameterization
Action Parameters
While recording the script into
multiple actions user need to objerve 3 points.
1. Along with a new action QTP
adds a new data sheet in Data Table with action name.
2. Object Repository also records
into multpile actions.
3. QTP adds a statement in the
action which navigates the script run to the new action.
RunAction "ActionName",
OneIteration
Note: User can record upto 255 actions
If User changes the Name of the
Action it will applies in the Repository and Data Table also.
All recorded actions will treats
as Internal Actions and allows modifications from the user.User can change the
navigation of Actions.User can split one action into two actions.
Copy Of Action: User can select one action from
one test into another test to copy.Only selected action will copied. (Nested
action will not copied)User can update the copied action.no relation between
source action and copied action.both will treats as internal actions.
Call to Existing Actions: It calls the selected action along with its
nested actions.
All these are External actions
and not allowed any modifications modifications on source will effects here.
Action Parameterization
~~~~~~~~~~~~~~~~~~~~
1. Enter the Test Data into the
specific action sheet
2. Open the script in Keyword view
3. Open the Action you need to parameterize and perform it.
4. Open its parent action and select the Action
name(RunAction) and right click it
5. Select Action Call Properties
and change the data table iterations
Note: Parameterized action should
not contain child actions which navigates into different screens
AddDefectToQC
Dim TDConnection
Set TDConnection =
CreateObject("TDApiOle.TDConnection")
TDConnection.InitConnection
"http://yovav/tdbin" ' URL for the DB
TDConnection.ConnectProject
"TD76","bella","pino" ' Valid login information
If TDConnection.Connected Then
MsgBox("Connected to "
+ chr (13) + "Server " + TDConnection.ServerName _
+ chr (13) +"Project "
+ TDConnection.ProjectName )
Else
MsgBox("Not Connected")
End If
'Get the IBugFactory
Set BugFactory = TDConnection.BugFactory
'Add a new empty bug
Set Bug = BugFactory.AddItem
(Nothing)
'fill the bug with relevant
parameters
Bug.Status = "New"
Bug.Summary = "Connecting to
TD"
Bug.Priority = "4-Very
High" ' depends on the DB
Bug.AssignedTo =
"admin" ' user that must exist in the DB's users list
Bug.DetectedBy =
"admin" ' user that must exist in the DB's users list
'Post the bug to DB ( commit )
Bug.Post
AdvancedVBScripts
' Read from XML
' ~~~~~~~~~~~~~
Dim objXML, Root, node
set objXML =
CreateObject("Microsoft.XMLDOM")
objXML.async = "false"
objXML.load("d:\myfile.xml")
Set Root = objXML.documentElement
For Each node In Root.childNodes
if
node.nodename="Variable" then
itemname=node.text
MsgBox
itemname
End
If
Next
set objXML = Nothing
Set Root = Nothing
' ~~~~~~~~~~~~~~~~~~~~~~~~~
' Create a Word Document
' ~~~~~~~~~~~~~~~~~~~~~~~
Dim objWD
Set objWD =
CreateObject("Word.Application")
objWD.Documents.Add
objWD.Selection.TypeText
"Hello" & Chr(13) & "How are you Doing"
objWD.ActiveDocument.SaveAs
"D:\mydoc.doc"
objWD.Quit
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Send a mail to outlook
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set objLook =
CreateObject("OutLook.Application")
Set objMail =
ObjLook.CreateItem(0)
objMail.Subject = "Test
Result"
objMail.To =
"surya.boddu@hitachiconsulting.com"
'objMail.cc = "mail
ids"
objMail.Attachments.Add
"D:\SuryaQTP\Vbscript.doc"
objMail.HtmlBody = "Test
Message"
objMail.send
Set objLook = Nothing
' ~~~~~~~~~~~~~~~~~~~~~~~
' Create an Excel file
' ~~~~~~~~~~~~~~~~~~~~
Set Ex =
CreateObject("Excel.Application")
Ex.WorkBooks.Add
Ex.ActiveWorkBook.SaveAs
"C:\My1.xls"
Set WBK =
Ex.WorkBooks.Open("C:\My1.xls")
Set Wst = WBK.Sheets(1)
Wst.Name = "My sheet"
Wst.Rows("1:5").Font.Name
= "Comic Sans Ms"
Wst.Cells(1,1) = "Rama"
Wst.Columns("A:D").Font.bold
= True
Wst.Columns("A:D").Columnwidth
= 40
Wst.Rows("1:5").Font.Size
= 10
WBK.Save
'WBK.Copy "target"
Ex.Quit
Set Ex = Nothing
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Create a Dictionary Object
(Named Arrays)
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim myDictObj
Set
myDictObj=CreateObject("Scripting.Dictionary")
myDi.Add
"CustId","1001"
'Add some keys and items
myDi.Add "CustName",
"Pradeep"
myDi.Add
"CustCity","Hyd"
Msgbox
myDictObj.Item("CustName")
Msgbox myDictObj.Count
myKeys = myDi.Keys
For each Item in myKeys
Msgbox Item
'Returns the array to see individual key values
Next
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' To restart/shutdown/Logoff a
System
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim wsh
Set wsh =
CreateObject("Wscript.Shell")
wsh.Run "Sutdown.exe
-l" ' for Logoff
wsh.Run "shutdown.exe
-r" ' for restart
wsh.Run "shutdown.exe
-s" - for shutdown
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' To display a popup with time
limit
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim wsh
Set wsh =
CreateObject("Wscript.Shell")
'wsh.Popup "Your
message", timeout, "Title"
wsh.Popup "How do you
do?", 5, "Hello"
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Automated Testing Life-cycle Methodology (ATLM)[i]
Elfriede Dustin
Software
project managers and software developers building today's applications face the
challenge of doing so within an ever-shrinking schedule and with minimal
resources. As part of their attempt to do more with less, organizations want to
test software adequately, but as quickly and thoroughly as possible. To
accomplish this goal, organizations are turning to automated testing.
Faced
with this reality and realizing that many tests cannot be executed manually,
such as simulating 1,000 virtual users for volume testing, software
professionals are introducing automated testing to their projects. While
needing to introduce automated testing, software professionals may not know
what's involved in introducing an automated test tool to a software project,
and they may be unfamiliar with the breadth of application that automated test
tools have today. The Automated Testing
Life-cycle Methodology (ATLM), depicted in Figure 1, provides guidance in these
areas.
Figure 1 -
Automated Test Lifecycle Methodology (ATLM)
By using the
systematic approach outlined within the ATLM, organizations are able to
organize and execute test activities in such a way as to maximize test coverage
within the limits of testing resources.
This structured test methodology involves a multi-stage process,
supporting the detailed, and inter-related activities that are required to
introduce and utilize an automated test tool; develop test design; develop and
execute test cases; develop and manage test data and the test environment; as
well as document, track and obtain closure on issue/trouble reports.
Clearly,
the emphasis on automated testing represents a paradigm change for the software
industry. This change does not simply involve the application of tools and the
performance of test automation. Rather, it is pervasive across the entire test
life cycle and the system development life cycle. The ATLM implementation takes
place in parallel with the system development lifecycle. For software professionals to successfully
make the leap to automated testing, structured approaches to testing must be embraced. The ATLM is revolutionary in the fact that it
promulgates a new structured, building-block approach to the entire test life
cycle, which enables software test professionals to approach software testing
in a methodical and repeatable fashion.
The
growth of automated test capability has stemmed in large part from the growing
popularity of the iterative and incremental development life cycle, a software
development methodology that focuses on minimizing the development schedule
while providing frequent, incremental software builds. The objective of this
incremental and iterative development is to engage the user and the test team
early throughout design and development of each build so as to refine the
software, thereby ensuring that it more closely reflects the needs and
preferences of the user and thus addressing the riskiest aspects of development
in early builds
In this
environment of continual changes and additions to the software through each
software build, software testing takes on an iterative nature itself. Each new
build is accompanied by a considerable number of new tests as well as rework to
existing test scripts, just as there is rework on previously released software
modules. Given the continual changes and additions to software applications,
especially web applications, automated software testing becomes an important
control mechanism to ensure accuracy and stability of the software through each
build.
The ATLM,
invoked to support test efforts involving automated test tools, incorporates a
multi-stage process. The methodology supports the detailed and inter-related
activities that are required to decide whether to acquire an automated testing
tool. The methodology includes the
process of how to introduce and utilize an automated test tool, covers test
development and test design, and addresses test execution and management. The
methodology also supports the development and management of test data and the
test environment, and addresses test documentation to include problem
reports.
The ATLM methodology represents a
structured approach, which depicts a process with which to approach and
execute test. This structured approach is necessary to help steer the test team away from the common test program
mistakes below.
- Implementing the use of an automated test tool without a testing process in place resulting in an ad-hoc, non-repeatable, non-measurable test program.
- Implementing a test design without following any design standards, resulting in the creation of test scripts that are not repeatable and therefore not reusable for incremental software builds.
- Efforts attempting to automate 100% of test requirements, when tools or in-house developed automated test harnesses being applied do not support automation of all tests required.
- Using the wrong tool or developing a too elaborate in house test harness.
- Test tool implementation initiated too late in the application development life cycle, not allowing sufficient time for tool setup and test tool introduction process (i.e. learning curve).
- Test engineer involvement initiated too late in the application development life cycle resulting in poor understanding of the application and system design, which results in incomplete testing.
The Automated Test Life-cycle Methodology (ATLM) is comprised of
six primary processes or components. Each
primary process is further composed of subordinate processes as described
below.
1 Decision to Automate Test
The Decision to
Automate Test represents the first phase of the ATLM. This phase covers the entire process that
goes into the automated testing decision. During this phase it is important for
the test team to manage automated testing expectations and to outline the
potential benefits of automated testing when implemented correctly. A test tool
proposal needs to be outlined, which will be helpful in acquiring management
support.
1.1
Overcoming False Expectations for Automated Testing
While it has
been proven successfully that automated testing is valuable and can produce a
return on investment, there isn’t always an immediate payback on investment. It
is important that some of the misconceptions that persist in the software
industry are addressed and that the automated testing utopia is managed. What
follows is a list of just a few of the misconceptions that need to be
addressed. It is important to note that people often see test automation as a
silver bullet and, when they find that test automation requires a significant
short-term investment of time and energy to achieve a long-term return on
investment (ROI) of faster and cheaper regression testing (for example), the
testing tool often becomes “shelf-ware” the tool. This is why it is important
that in order to introduce automated testing correctly into a project,
expectations are managed.
Automatic Test Plan Generation
Currently, there is no commercially available tool that can
automatically create a comprehensive test plan, while also supporting test
design and execution.
Throughout a software test
career, the test engineer can expect to witness test tool demonstrations and
review an abundant amount of test tool literature. Often the test engineer will be asked to
stand before a senior manager or a small number of managers to give a test tool
functionality overview. As always the
presenter must bear in mind the audience.
In this case, the audience may represent individuals with just enough
technical knowledge to make them enthusiastic about automated testing, while
not aware of the complexity involved with an automated test effort. Specifically, the managers may have obtained
information about automated test tools third hand, and may have reached the
wrong interpretation of the actual capability of automated test tools.
What the audience at the
management presentation may be waiting to hear, is that the tool that you are
proposing automatically develops the test plan, designs and creates the test
procedures, executes all the test procedures and analyzes the results
automatically. You meanwhile start out
the presentation by informing the group that automated test tools should be
viewed as enhancements to manual testing,
and that automated test tools will not automatically develop the test plan,
design and create the test procedures and execute the test procedures.
Soon into the presentation and
after several management questions, it becomes very apparent just how much of a
divide exists between the reality of the test tool capabilities and the
perceptions of the individuals in the audience.
The term automated test tool
seems to bring with it a great deal of wishful thinking that is not closely aligned
with reality. An automated test tool
will not replace the human factor necessary for testing a product. The
proficiencies of test engineers and other quality assurance experts will still
be needed to keep the testing machinery running. A test tool can be viewed as an additional
part of the machinery that supports the release of a good product.
Test Tool
Fits All
Currently not one single test tool exists that can be used to
support all operating system environments.
Generally, a single test tool will not fulfill all the testing
requirements for an organization.
Consider the experience of one test engineer encountering such a
situation. The test engineer, Dave, was
asked by a manager to find a test tool that could be used to automate the
testing of all of the department’s applications. The department was using
various technologies to include mainframe computers and Sun workstations;
operating systems such as Windows 3.1, Windows 95 and Windows NT, Windows 2000,
programming languages such as VC++, and Visual Basic, other client server
technologies and web technologies, such as DHTML, XML, ASP, etc.
After
conducting a tool evaluation, the test engineer determined that the tool of
choice was not compatible with the VC++ third party add-ons (in this case, Stingray
grids). Another tool had to be brought in, that was compatible with this
specific application.
It is important
to note that expectations have to be managed and it has to be made clear that
currently there does not exist one single tool on the market that is compatible
with all of the operating systems and programming languages
simultaneously. More than one tool is
required to test the various technologies.
Immediate Reduction in Schedule – An
automated test tool will not immediately minimize the testing schedule.
Another automated test
misconception is the expectation that the use of an automated testing tool on a
new project will immediately minimize the test schedule. Since the testing effort actually increases,
as previously described, the testing schedule will not experience the
anticipated decrease at first, and an allowance for schedule increase is
required, when initially introducing an automated test tool. This is due to the fact that when rolling out
an automated test tool, the current testing process has to be augmented or an
entirely new testing process has to be developed and implemented. The entire test team and possibly the
development team needs to become familiar with this new automated testing
process (i.e. ATLM) and needs to follow it. Once an automatic testing process
has been established and effectively implemented, the project can expect to
experience gains in productivity and turn around time that have a positive
effect on schedule and cost.
1.2
Benefits
of Automated Testing
The previous discussion points
out and clarifies some of the false automated testing expectations that exist.
The test engineer will also need to be able to elaborate on the benefits of
automated testing, when automated testing is implemented correctly and a process
is followed. The test engineer must
evaluate whether potential benefits fit required improvement criteria and
whether the pursuit of automated testing on the project is still a logical fit,
given the organizational needs. There
are three significant automated test benefits (in combination with manual test)
which include a) producing a reliable system, b) improving the quality of the
test effort, and c) reducing test effort and minimizing schedule.
Many return on investment case
studies have been done with regard to the implementation of automated testing.
One example is a research effort conducted by imbus GmbH (see www.imbus.de). They conducted a test automation
value study in order to collect test automation measurements with the purpose
of studying the benefits of test automation versus the implementation of manual
test methods. Their research determined
that the break-even point of automated testing is on average at 2.03 test runs
(see www.imbus.de for more detail)[ii].
1.3
Acquiring
management support
Whenever an
organization tries to adopt a new technology, they encounter a significant
effort when determining how to apply it to their needs. Even with completed
training, organizations wrestle with time-consuming false starts before they
become capable with the new technology.
For the test team interested in implementing automated test tools, the
challenge is how to best present the case for a new test automation technology
and its implementation to the management team.
Test engineers need to influence
management’s expectations for the use of automated testing on projects. Test engineers can help to manage
expectations of others in the organization by forwarding helpful information to
the management staff. Bringing up test
tool issues during strategy and planning meetings can also help develop better
understanding of test tool capabilities of everyone involved on a project or
within the organization. A test engineer
can develop training material on the subject of automated testing and can
advocate to management that a seminar be scheduled to conduct the training.
The first step in moving toward a
decision to automate testing on a project requires that the test team adjust
management understanding of the appropriate application of automated testing
for the specific need at hand. The test
team, for example, needs to check early on whether management is cost adverse
and would be unwilling to accept the estimated cost of automated test tools for
a particular effort. If so, test
personnel need to convince management about the potential return on investment
by conducting cost benefit analysis.
If management is willing to
invest in an automated test tool, but is not able or willing to staff a test
team with individuals having the proper software skill level or provide for
adequate test tool training, the test team will need to point out the risks
involved and/or may need to reconsider a recommendation to automate test.
Management also
needs to be made aware of the additional cost involved when introducing a new
tool, not only for the tool purchase, but for initial schedule/cost increase,
additional training costs and for enhancing an existing testing process or
implementing a new testing process.
Test automation
represents highly flexible technology, which provides several ways to
accomplish an objective. Use of this
technology requires new ways of thinking, which only amplifies the problem of
test tool implementation. Many organizations can readily come up with examples
of their own experience of technology that failed to deliver on its potential
because of the difficulty of overcoming the "Now what?" syndrome. The
issues that organizations face when adopting automated test systems include
those outlined below.
·
Finding/hiring test tool experts
·
Using the correct tool for the task at hand
·
Developing and implementing an automated testing
process, which includes developing automated test design and development
standards
·
Analyzing various applications to determine
those which are best suited for automation
·
Analyzing the test requirements to determine the
ones suitable for automation
·
Training the test team on the automated testing
process, automated test design, development and execution.
·
Initial increase in schedule and cost
2
Test Tool
Acquisition
Test Tool
Acquisition represents the 2nd
phase of the ATLM. This phase guides the test engineer through the entire test
tool evaluation and selection process, starting with confirmation of management
support. Since a tool should support
most of the organizations’ testing requirements, whenever feasible, the test
engineer will need to review the systems engineering environment and other
organizational needs and come up with a list of tool evaluation criteria. A
review of the different types of tools available to support aspects of the
entire testing life-cycle is provided in the book Automated Software Testing (as
part of the ATLM), enabling the reader to make an informed decision with regard
to the types of tests to be performed on a particular project. The test
engineer then needs to define an evaluation domain to pilot the test tool.
Finally, after all those steps have been completed, the test engineer can make
vendor contact to bring in the selected tool(s). Test personnel then evaluate the tool, based
on sample criteria provided.
3
Automated
Testing Introduction Phase
The Process of
Introducing Automated Testing to a new project team represents the 3rd
phase of the ATLM. This phase outlines the steps necessary to successfully
introduce automated testing to a new project, which are summarized below.
Test Process Analysis
Test Process
Analysis ensures that an overall test process and strategy are in place and are
modified, if necessary, to allow automated test to be introduced in a
successful fashion. The test engineers
define and collect test process metrics in order to allow for process
improvement. Here test goals, objectives and strategies need to be defined and
test process needs to be documented and communicated to the test team. In this phase, the kinds of testing
applicable for the technical environment will be defined and tests are defined
that can be supported by automated tools.
During the
test process analysis, techniques get defined. Best practices, such as
conducting performance testing during the unit-testing phase are laid out.
Plans for user
involvement are assessed, and test team personnel skills are analyzed against
test requirements and planned test activities. Early test team participation is
emphasized, supporting refinement of requirement specifications into terms,
which can be adequately tested while also supporting test team understanding of
application requirements and design.
Test Tool Consideration
The Test Tool
Consideration phase includes steps that investigate whether incorporation of
automated test tools that have been brought into the company without a specific
project in mind now would be beneficial to a specific project, given the
project testing requirements, available test environment and personnel
resources, the user environment, platform, and product features of the
application under test. Schedule is
reviewed to ensure sufficient time for test tool setup and development of
requirements hierarchy; potential test tools and utilities are mapped to test
requirements; test tool compatibility with the application and environment is
verified; workaround solutions are investigated to incompatibility problems
surfaced during compatibility tests.
4
Test
Planning, Design and Development
Test Planning,
Design and Development is the 4th phase of
the ATLM. These subjects are summarized
below.
Test Planning
The Test Planning phase represents the need to review long
lead-time test planning activities.
During this phase, the test team identifies test procedure creation
standards and guidelines; hardware, software and network required to support
test environment; test data requirements; a preliminary test schedule;
performance measure requirements; a procedure to control test configuration and
environment; defect tracking procedure and associated tracking tool.
The test plan
contains the results of each preliminary phase of the structured test
methodology (ATLM). The test plan will define roles and responsibilities,
project test schedule, test planning and design activities, test environment
preparation, test risks and contingencies, and
acceptable level of thoroughness (i.e. test acceptance criteria). Test plan
appendices may include test procedures, naming convention description, test
procedure format standards and a test procedure traceability matrix.
The Test
Environment Setup is part of test planning. It represents the need to plan,
track and manage test environment set up activities, where material
procurements may have long lead-times. The test team needs to schedule and
track environment set up activities; install test environment hardware,
software and network resources; integrate and
install test environment resources; obtain/refine test databases; and
develop environment setup scripts and test bed scripts.
Test Design
The Test Design component
addresses the need to define the number of tests to be performed, the ways that
test will be approached (paths, functions), and the test conditions which need
to be exercised. Test design standards need to be defined and followed.
An
effective test program, incorporating the automation of software testing,
involves a mini-development life cycle of its own, complete with strategy and
goal planning, test requirement definition, analysis, design and coding. Similar to software application development,
test requirements must be specified before test design is constructed. Test
requirements need to be clearly defined and documented, so that all project
personnel will understand the basis of the test effort. Test requirements are defined within
requirement statements as an outcome of test requirement analysis.
After Test
Requirements have been derived using the described techniques, test procedure
design can begin. Test procedure definition consists of the definition of
logical groups of test procedures and a naming convention for the suite of test
procedures. With a test procedure
definition in place, each test procedure is then identified as either an
automated or a manual test. During the
test planning phase the test team gets an understanding of the number of test
techniques being employed and an estimate for the number of test procedures
that will be required. The test team also will have an estimate of the number
of test procedures that will need to be performed manually, as well as with an
automated test tool.
Much
like a software development effort, the test program must be mapped out and
consciously designed to ensure that test activities performed represent the
most efficient and effective tests for the system under test. Test program resources are limited, yet ways
of testing the system are endless. Test
design is developed, which portrays the test effort, in order to give project
and test personnel a mental framework on the boundary and scope of the test
program.
Following
test analysis, the test team develops the test program design models. The first of these design models, the Test
Program Model, consists of a graphic illustration that depicts the scope of the
test program. This model typically
depicts the test techniques required to support the dynamic test effort and
also outline static test strategies.
Having
defined a test program model, the test team constructs a test architecture,
which depicts the structure of the test program, and defines the way that test
procedures will be organized in support of the test effort.
The next step in the test
procedure design process as depicted in Table 1, is to identify those test
procedures which stand out as being more sophisticated, and as a result, are
required to be defined further as part of detailed test design. These test procedures are flagged and a
detailed design document is prepared in support of the more sophisticated test
procedures. Following detailed test
design, test data requirements are mapped against the defined test procedures.
In order to create a repeatable, reusable process for producing test
procedures, the test team needs to create a document that outlines test
procedure design standards. Only when
these standards are followed can the automated test program achieve real
efficiency and success, by being repeatable and maintainable.
step
|
description
|
1
|
Test Architecture Review. The test team reviews the
test architecture in order to identify the test techniques which apply.
|
2
|
Test Procedure Definition (Development Level). A Test Procedure Definition is constructed
at the development test level, that identifies the test procedure series that
applies for the different design components and test techniques.
|
3
|
Test Procedure Definition
(System Level). A
Test Procedure Definition is constructed at the system test level, that
identifies the test procedure series that applies for the different test
techniques.
|
4
|
Test Procedure Design Standards. Design standards are adopted and
a naming convention is adopted that uniquely identifies the test procedures
on the project from test procedures developed in the past or on other
projects.
|
5
|
Manual Versus Automated Tests.
Test procedures will be depicted as being either performed manually or
as part of an automated test.
|
6
|
Test Procedures Flagged for
Detailed Design. Test procedures that stand out as more
sophisticated are flagged. These test
procedures are further defined as part of detailed test design.
|
7
|
Detailed Design. Those test procedures flagged as part of step
above, are designed in further detail within a Detailed Test Design file or
document. Test procedure detailed
design may consist of pseudocode of algorithms, preliminary test step
definition, or pseudocode of test automation programs.
|
8
|
Test Data Mapping. Test Procedure Matrix is
modified to reflect test data requirements for each test procedure.
|
Table 1 - Test Procedure Design Process
The
exercise of developing the test procedure definition not only aids in test
development, but this definition also helps to quantify or bound the test
effort. The development of the test
procedure definition involves the identification of the suite of test
procedures that will need to be developed and executed in support of the test
effort. The design exercise involves the organization of test procedures into
logical groups and the definition of a naming convention for the suite of test
procedures.
At
the system level, it may be worthwhile to develop a detailed test design for
sophisticated tests. These tests might
involve test procedures that perform complex algorithms, consist of both manual
and automated steps, and test programming scripts that are modified for use in
multiple test procedures. The first step in the detailed design process is to
review the test procedure definition at the system test level. This review is
conducted for the purpose of identifying those test procedures that stand out
as being more sophisticated, which as a result, are required to be defined
further as part of detailed test design.
Detailed test design may take the
form of test program pseudocode, when test programming is required. The detailed design may be represented simply
as a sequence of steps that need to be performed in support of a test. When programming variables and multiple data
values are involved, the detailed design may reflect the programming construct
of a loop supporting an iterative series of tests involving different values
together with a list or table identifying the kinds of data or ranges of data
required for the test.
Following
the performance of detailed test design, test data requirements need to be
mapped against the defined test procedures.
Once test data requirements are outlined, the test team needs to plan
the means for obtaining, generating or developing the test data.
The
structure of the test program (test architecture) is commonly portrayed in two
different ways. One test procedure
organization method involves the logical grouping of test procedures with the
system application design components, and is referred to as a design-based test
architecture. Another method represents
a test technique perspective and associates test procedures with the various
kinds of test techniques represented within the test program model, and is
referred to as a technique-based test architecture.
An
understanding of test techniques is necessary when developing test design and
the test program design models.
Personnel performing test need to be familiar with the test techniques
associated with the white box and black box test approach methods. White box test techniques are aimed at
exercising software program internals, while black box techniques generally
compare the application under test behavior against requirements that address
testing via established, public interfaces such as the user interface or the
published application programming interface (API).
Test Development
In order for automated tests to be reusable, repeatable and
maintainable, test development standards need to be defined and followed.
After performing test analysis
and design the test team is now ready to perform test development.
Keep in mind that the test design
and development activities follow an iterative and incremental approach, in
order to address the highest risk functionality up front. Table 2 correlates
the development process phases to the test process phases. The testing
processes and steps outlined in the table are strategically aligned with the
development process and the execution of these steps results in the refinement
of test procedures at the same time as developers are creating the software
modules. Automated and/or manual test procedures are developed during the
integration test phase with the intention of reusing them during the system
test phase.
Many preparation activities need to take place, before test
development can begin. A test development architecture is developed (Figure 2),
which provides the test team with a clear picture of the test development
preparation activities or building blocks necessary for the efficient creation
of test procedures. The test team will need to modify and tailor the sample
test development architecture in order to reflect the priorities of their
particular project. Part of these setup and preparation activities include the
need to track and manage test environment set up activities, where material
procurements may have long lead-times.
Prior to the commencement of test development, the test team also needs
to perform analysis to identify the potential for reuse of already existing
test procedures and scripts within the Automation Infrastructure (reuse
library).
The test team needs to develop test procedures according to a test
procedure development/execution schedule.
This schedule needs to allocate personnel resources and reflect
development due dates, among other factors.
The test team needs to monitor development progress and produce progress
status reports. Prior to the creation of
a complete suite of test procedures, the test team performs a modularity
relationship analysis. The results of
this analysis help to incorporate data dependencies, plan for workflow
dependencies between tests, and identify common scripts that can be repeatedly
applied to the test effort. As test
procedures are being developed, the test team needs to ensure that
configuration control is performed for the entire test bed to include test
design, test scripts, and test data, as well as for each individual test
procedure. The test bed needs to be baselined using a configuration management
tool.
Test development involves the
development of test procedures that are maintainable, reusable, simple and
robust, which in itself can be as challenging as the development of the
application-under-test. Test procedure development standards need to be in
place supporting structured and consistent development of automated tests. Test
development standards can be based on the scripting language standards of a
particular test tool. For example,
Rational’s Robot uses SQABasic, a Visual Basic like scripting language and
therefore the script development standards could be based on the Visual Basic
development standards, outlined in a number of books on the subject.
Usually internal development
standards exist that can be followed if the organization is developing in a
language similar to the tool’s scripting language. The adoption or slight
modification of existing development standards is generally a better approach
than creating a standard from scratch. If no development standards exist within
the organization for the particular tool scripting language, it is important
for the test team to develop script development guidelines. Such guidelines can
include directions on context
independence, which addresses the particular place where a test procedure
should start and where it should end.
Additionally, modularity and reusability guidelines need to be addressed.
Phase
|
Development Process
|
Test Process
|
Module (Unit) Development
|
Design module from requirements
|
Perform test planning and test
environment set up.
|
Code module
|
Create test design and develop
test data.
|
|
Debug module
|
Write test scripts or record
test scenario using module.
|
|
Unit test module
|
Debug automated test script by
running against module. Use tools that support unit testing,
|
|
Correct defects
|
Rerun automated test script to
regression test as defects are corrected.
|
|
Conduct
Performance Testing
|
Verify system is scaleable and
will meet performance requirements
|
|
Integration
|
Build
system by connecting modules.
Integration
test connected modules.
Review
trouble reports.
|
Combine unit test scripts and
add new scripts that demonstrate module inter-connectivity. Use test tool to support automated
integration testing.
|
Correct defects and update
defect status.
|
Rerun automated test script as
part of regression test, as defects are corrected.
|
|
Continued Performance Testing
Activities
|
Verify system is scaleable and
will meet performance requirements
|
|
System Test
|
Review trouble reports.
|
Integrate automated test
scripts into system level test procedures, where possible, and develop
additional system level test procedures. Execute system test and record test
results.
|
Correct defects and update
defect status.
|
Rerun
automated test script as part of regression test as defects are corrected.
|
|
Acceptance Test
|
Review incident reports.
|
Perform
subset of system test as part of demonstration of user acceptance test.
|
Correct defects
|
Rerun
automated test script as part of regression test as defects are corrected.
|
Table 2 - Development / Test Relationship
By developing test procedures
based on development guidelines, the test team creates the initial building
blocks for an Automation Infrastructure.
The Automation Infrastructure will eventually contain a library of
common, reusable scripts. Throughout the
test effort and in future releases, the test engineer can make use of the
Automation Infrastructure in order to support reuse of archived test procedures,
minimize duplication, and thus enhance the entire automation effort.
Test Development Architecture
Test team members responsible for
test development need to be prepared with the proper materials. Test team personnel need to follow a test
development architecture that includes, for example, a listing of the test
procedures assigned to them and a listing of the outcome of automated vs.
manual test analysis. Also, test team personnel will need to decide when to
automate. At times a test team might want to avoid automating using a GUI
testing tool before the interface –whether API, character UI, or GUI is
stabilized to avoid re-engineering the automated tests in response to
non-bug-related changes. Other times the
test team can find workaround solutions when automating an unstable GUI, such
as focusing automation on the known stable parts only.
The test engineer needs to adhere
to the test procedure development and execution schedule, test design
information, automated test tool user manuals, and test procedure development
guidelines. Armed with the proper instructions, documentation and guidelines,
test engineers will have the foundation that allows them to develop a more
cohesive and structured set of test procedures. It is important to note that
the ability for the test team to repeat a process and repeatedly demonstrate a
strong test program, depends upon the availability of documented processes and
standard guidelines such as the test development architecture.
An example of the graphical
illustration, containing the major activities to be performed as part of the
test development architecture, is depicted in Figure 2. Test development starts
with test environment setup and preparation activities, discussed previously.
Once they are concluded, the test team needs to make sure that pertinent
information, necessary to support development has been documented or gathered.
The test team will need to modify and tailor the sample test development
architecture, depicted in Figure 2, in order to reflect the priorities of their
particular project. Note that Figure 2
should be read from bottom to top.
Figure 2 - Building
Blocks of the Test Development Architecture
Technical
Environment
Test procedure development needs
to be preceded by several setup activities. The test development activity needs
to be supported by a technical environment, which facilitates the development
of test procedures. As a result, the
test environment needs to be set up and ready to go. The test environment
includes the technical environment, which may include facility resources as
well as the hardware and software necessary to support test development and
execution. The test team needs to ensure that there are enough workstations to
support the entire team. The various
elements of the test environment need to be outlined within the test plan, as
discussed previously.
Environment setup activities can
also include the use of an environment setup script to load test data restore a
drive image, and to calibrate the test tool to the environment. When test tool
compatibility problems arise with the application under test, workaround
solutions have to be identified. When developing test procedures it is
important that the schedule for developing test procedures is consistent with
the test execution schedule. It is also
important that the test team follow test procedure development guidelines.
The test team will need to ensure
that the proper test room or laboratory facilities are reserved and setup. Once the physical environment is
established, the test team will need to ensure that all necessary equipment is
installed and operational. The test plan defined the required technical
environment and addressed test environment planning. Also within the test environment section of
the test plan, the test team has already identified operational support
required to install and checkout the operational readiness of the technical
environment. The test team needs to ensure that operational support activities
have been properly scheduled and must monitor progress of these tasks.
Specific tasks and potential
issues outlined in the test plan should have now been addressed and
resolved. Such issues could include
network installation, network server configuration and allocated disk space,
network access privileges, required desktop computer processing speed and
memory, number and types of desktop computers (clients), video resolution
requirements, and any additional software required to support the application
such as browser software. Automated test
tools that apply should have been scheduled for installation and checkout.
These tools now should be configured to support the test team and be
operational within the test environment.
The test environment setup
activity includes the need to track and manage test environment set up
activities, where material procurements may have long lead-times. These activities include the need to schedule
and track environment set up activities; install test environment hardware,
software and network resources; integrate and test install test environment
resources; obtain/refine test databases; and develop environment setup scripts
and test bed scripts.
The hardware supporting the test
environment must be sufficient to ensure complete functionality of the
production application. Test environment
hardware needs to be sufficient to support performance analysis. In cases where
the test environment utilizes hardware resources, which are also supporting
other development or management activities, special arrangements may be
necessary during actual performance testing.
During system test, the software configuration loaded within the test
environment must be a complete, fully integrated release with no patches and no
disabled sections. The hardware
configuration supporting the test environment needs to be designed to support
processing, storage, and retrieval activities, which may be performed across a
local or wide area network, reflecting the target environment.
The test environment design will
also need to consider stress testing requirements. Stress and load tests may require the use of
multiple workstations that will run multiple test procedures simultaneously,
while some automated test tools include a virtual user simulation functionality
that greatly eliminates or minimizes the need for multiple workstations.
Test data will need to be
obtained with enough lead-time to support refinement and manipulation to
support test requirements. Data
preparation activities include the identification of conversion data
requirements, the preprocessing of raw data files, loading of temporary tables
possibly in a relational database management system format, and the performance
of consistency checks. Identifying
conversion data requirements involves performing in-depth analysis on data
elements, which includes defining data mapping criteria, clarifying data
element definitions, confirming primary keys, and defining data-acceptable
parameters.
During test planning, the test
team defined and scheduled the test environment activities. Now the team will
need to track the test environment set up activities. Resources need to be identified to install
hardware, software and network resources into test environment and integrate
and test installed test environment resources.
The test environment materials and the application under test need to be
baselined within a configuration management tool. Additionally, test environment materials may
include test data and test processes.
The test team will need to obtain
and modify test databases necessary to exercise software applications, and
develop environment setup scripts and test bed scripts. The test team should perform product reviews and validation of all test source
materials. The location of the test environment for each project or task
should be defined within the test plan for each project. Early identification of the test site is
critical to cost effective test environment planning and development.
5
Execution
and Management of Tests
The test team at this stage, has
addressed test design and test development. Test procedures are now ready to be
executed in support of exercising the application-under-test. Also test
environment setup planning and implementation was addressed consistent with the
test requirements and guidelines provided within the test plan.
With the
test plan in hand and the test environment now operational, it is time to
execute the tests defined for the test program. When executing test procedures,
the test team will need to comply with a test procedure execution schedule, as
discussed previously. The test procedure
execution schedule implements the strategy defined within the test plan. Plans
for unit, integration, system and user acceptance testing are executed.
Together, these testing phases make up the steps that are required to test the
system as a whole.
The various steps involved during
execution and management of tests are outlined below.
When
executing test procedures, the test team will need to comply with a test
procedure execution schedule. Following
test execution, test outcome evaluations are performed and test result
documentation is prepared.
Plans
for unit, integration, system and user acceptance testing are executed, which
together make up the steps that are required to test the system as a
whole. During the unit test phase, code
profiling can be performed. Traditionally, profiling is a tuning process that
determines whether an algorithm is inefficient or a function is being called
too frequently. Profiling can discover instances where there is improper
scaling of algorithms, instantiations and resource utilization.
Integration
testing is performed which focuses on the application internals. During integration testing, units are
incrementally integrated and tested together based upon control flow. Since units may consist of other units, some
integration testing, also called module testing, may take place during unit
testing.
During
system test, the test engineer is testing the integration of parts, which
comprise the entire system. A separate test team usually performs system-level
tests. The test team implements the test
procedure execution schedule and the system test plan.
The
test team also performs analysis to identify particular components or
functionality that are experiencing a greater relative number of problem
reports. As a result of this analysis,
additional test procedures and test effort may need to be assigned to the
components. Test results analysis can
also confirm whether executed test procedures are proving to be worthwhile in
terms of identifying errors.
Each
test team needs to perform problem-reporting operations in compliance with a
defined process. The documentation and tracking of software problem reports is
greatly facilitated by an automated defect-tracking tool.
The
test team manager is responsible for ensuring that tests are executed according
to schedule, and test personnel are allocated and redirected when necessary to
handle problems that arise during the test effort. In order to perform this oversight function
effectively, the test manager needs to perform test program status tracking and
management reporting.
Test metrics provide the test
manager with key indicators of the test coverage, progress, and the quality of
the test effort. During white box
testing the test engineer measures the depth
of testing, by collecting data relative to path coverage and test
coverage. During black box testing, metrics
collection focuses on the breadth of testing to include the amount of
demonstrated functionality and the amount of testing that has been performed.
6
Test Program
Review and Assessment
Test
Program review and assessment activities need to be conducted throughout the
testing life-cycle, in order to allow for continuous improvement activities.
Throughout the testing life-cycle and following test execution activities,
metrics need to be evaluated and final review and assessment activities need to
be conducted to allow for process improvement.
The
various steps necessary for test program review and assessment are outlined
below.
Following test execution, the
test team needs to review the performance of the test program in order to
determine where improvements can be implemented to improve the test program
performance on the next project. This
test program review represents the final phase of the Automated Test Life-cycle
Methodology (ATLM).
Throughout
the test program, the test team collected various test metrics. The focus of
the test program review includes an assessment of whether the application
satisfies acceptance criteria and is ready to go into production. The review also includes an evaluation of
earned value progress measurements and other metrics collected.
The
test team needs to adopt, as part of its culture, an ongoing iterative process
of lessons learned activities. Such a
program encourages test engineers to take the responsibility to raise
corrective action proposals immediately, when such actions potentially have
significant impact on test program performance.
Throughout
the entire test life cycle, it is good practice to document and begin to
evaluate lessons learned at each
milestone. The metrics that are
collected throughout the test life-cycle and especially during the test
execution phase help pinpoint problems that need to be addressed.
Lessons
learned, metrics evaluations and corresponding improvement activity or
corrective action need to be documented throughout the entire test process in a
central repository that is easily accessible.
After
collecting lessons learned and other metrics, and defining the corrective
actions, test engineers also need to assess the effectiveness of the test
program to include an evaluation of the
Test Program Return on Investment.
Test engineers capture measures of the benefits of automation realized
throughout the test life-cycle in order to support this assessment.
Test
teams can perform their own surveys to inquire about the potential value of process
and tool changes. A sample survey form
is provided that can be used to solicit feedback on the potential use of
requirement management tools, design tools, and development tools. Surveys are
helpful to identify potential misconceptions, and gather positive feedback.
Summary
ATLM is a structured methodology
that is geared toward ensuring successful implementation of automated testing.
The ATLM approach mirrors the benefits of modern rapid application development
efforts, where such efforts engage the user early in the development
cycle. The end-user of the software
product is actively involved throughout analysis, design, development and test
of each software build, which is augmented in an incremental fashion.
The ATLM incorporates a
multi-stage process consisting of six components. This methodology supports the
detailed and inter-related activities that are required to decide whether to
acquire an automated testing tool. The
methodology includes the process of how to introduce and best utilize an automated
test tool, and addresses test planning, analysis, design, development,
execution and management. The ATLM
requires that the scope of the test program be outlined within the test plan,
as a top-level description of test approach and implementation. The scope is further formulated through the
definition of test goals, objectives and strategies, and with the definition of
test requirements.
Similar to software application
development, test requirements are specified before test design is constructed. Likewise, the test program must be mapped out
and consciously designed to ensure that test activities performed represent the
most efficient and effective tests for the application under test. Test design is developed, graphically
portraying the test effort, in order to give project and test personnel a
mental framework on the boundary and scope of the test program.
For organizations, whose development is performed by relatively small project teams of less than eight people and who are seeking to introduce automated testing as a new practice, the ATLM practice should be tailored to reflect the size, capability and maturity of the project team and the organization. The scope and design of the test effort needs to encapsulate the highest priority test concerns, which might initially only address load performance testing. As the capabilities of the project team develop with the use of an automated testing tool and as the development environment of the organization becomes more mature from a life-cycle perspective, then the project team can expand the scope of the test effort and incorporate additional features of the ATLM.
Rational
Corporation lists the Automated Software Testing book and the (ATLM) as
recommended reading as part of the Rational Unified Process. Many universities and professional software test training organizations
have adopted the book for their classroom.
Many companies (such as Imbus GMBH, Moehrendorf Germany) have adopted the book and ATLM as their company standard
for automated software testing. Others
believe that industry automated test tool vendors will soon be incorporating
the book’s structured methodology within their tools. Instead of performing the entire test
life cycle haphazardly, software test managers will use an ATLM-compliant test
tool that automatically supports (and possibly enforces) the book’s sound
building block approach to the test effort.
Elfriede
Dustin may be contacted via her website at www.autotestco.com
[i] Adapted from “Automated Software
Testing”, Elfriede Dustin, et all, Addison Wesley Longman, Inc. July 1999
[ii] Linz, T., Daigl, M. GUI Testing
Made Painless. Implementation and Results
of the ESSI Project Number 24306. 1998. www.imbus.de.
CHAPTER 1
Test automation FRAMEWORK
This section gives the
introduction about test automation framework, various types of the framework
and the analysis of the best suitable framework for the application under test
(the application under test is referred as AUT). This also includes the
detailed description of the format of the input (the input to the framework is
referred as the test tables) that is given to our test automation framework.
1.1 RECORD/PLAYBACK MYTH
The test automation tool vendors market their product as the main
feature of the tool is the ability to capture the user actions and later to
playback them. Here is the basic paradigm for GUI-based automated regression
testing – the so called Record/Playback method (also called as Capture/Replay
approach)
1.
Design a test case in the test management tool.
2.
Using the capture feature of the automation testing tool record the user
actions. The result is a macro-like script where each user action is presented.
3.
Enhance the recorded script with verification points, where some property or
data is verified against an existing baseline. Add delay and wait states points
where the different actions are synchronized.
4.
Playback the scripts and observe the results in the log of the test management
tool.
The basic drawback in this
method is the scripts resulting from this method contain hard-coded values
which must change if anything at all changes in our AUT. The costs associated
with maintaining such scripts are astronomical, and unacceptable. These scripts
are not reliable, even if the application has not changed, and often fail on
replay (pop-up windows, messages, and other things can happen that did not
happen when the test was recorded).
If the tester makes an
error entering data, etc., the test must be re-recorded. If the application changes the test must be re-recorded.
All that is being tested are things that already work. Areas that have errors
are encountered in the recording process (which is manual testing, after all).
These bugs are reported, but a script cannot be recorded until the software is
corrected. So logically nothing is tested by this approach.
So, avoid using "Record/Playback" as
a method of automating testing. This method is fraught with problems, and is
the most costly (time consuming) of all methods over the long term. The
record/playback feature of the test tool is useful for determining how the tool
is trying to process or interact with the application under test, and can give
us some ideas about how to develop your test scripts, but beyond that, its
usefulness ends quickly.
1.2 TYPES OF TEST AUTOMATION FRAMEWORKS
As
we have eliminated Record/Playback method, let us explore about the existing
automation methodologies. There are several test automation frameworks available, among these the
selection is made based on the factors such as reusability of both the scripts
and the test assets. The different test automation frameworks available are as
follows,
Ø Test Script Modularity
Ø Test Library Architecture
Ø Data-Driven Testing
Ø Keyword-Driven or
Table-Driven Testing
Ø Hybrid Test Automation
1.2.1 Test Script
Modularity
The test
script modularity framework is the most basic of the frameworks. It's a
well-known programming strategy to build an abstraction layer in front of a
component to hide the component from the rest of the application. This
insulates the application from modifications in the component and provides
modularity in the application design. When working with test scripts (in any
language or proprietary environment) this can be achieved by creating small, independent
scripts that represent modules, sections, and functions of the application-
under-test. Then these small scripts are taken and combined them in a
hierarchical fashion to construct larger tests. The use of this framework will
yield a higher degree of modularization and add to the overall maintainability
of the test scripts.
1.2.2 Test Library
Architecture
The test
library architecture framework is very similar to the test script modularity
framework and offers the same advantages, but it divides the
application-under-test into procedures and functions (or objects and methods
depending on the implementation language) instead of scripts. This framework
requires the creation of library files (SQABasic libraries, APIs, DLLs, and
such) that represent modules, sections, and functions of the
application-under-test. These library files are then called directly from the
test case script. Much like script modularization this framework also yields a
high degree of modularization and adds to the overall maintainability of the
tests.
1.2.3 Data-Driven Testing
A data-driven
framework is where test input and output values are read from data files (ODBC
sources, CVS files, Excel files, DAO objects, ADO objects, and such) and are
loaded into variables in captured or manually coded scripts. In this framework,
variables are used for both input values and output verification values.
Navigation through the program, reading of the data files, and logging of test
status and information are all coded in the test script. This is similar to
table-driven testing (which is discussed shortly) in that the test case is
contained in the data file and not in the script; the script is just a
"driver," or delivery mechanism, for the data. In data-driven
testing, only test data is contained in the data files.
1.2.3.1 Merits of
data-driven testing
The merits of
the Data-Driven test automation framework are as follows,
Ø Scripts may be developed
while application development is still in progress
Ø Utilizing a modular design,
and using files or records to both input and verify data, reduces redundancy
and duplication of effort in creating automated test scripts
Ø If functionality changes,
only the specific "Business Function" script needs to be updated
Ø Data input/output and
expected results are stored as easily maintainable text records.
Ø Functions return
"TRUE" or "FALSE" values to the calling script, rather than
aborting, allowing for more effective error handling, and increasing the
robustness of the test scripts. This, along with a well-designed
"recovery" routine, enables "unattended" execution of test
scripts.
1.2.3.2
Demerits of data-driven testing
The demerits of the
Data-Driven test automation framework are as follows,
Ø Requires proficiency in the
Scripting language used by the tool (technical personnel)
Ø Multiple data-files are
required for each Test Case. There may be any number of data-inputs and
verifications required, depending on how many different screens are accessed.
This usually requires data-files to be kept in separate directories by Test
Case
Ø Tester must not only
maintain the Detail Test Plan with specific data, but must also re-enter this
data in the various required data-files
Ø If a simple "text
editor" such as Notepad is used to create and maintain the data-files,
careful attention must be paid to the format required by the scripts/functions
that process the files, or script-processing errors will occur due to data-file
format and/or content being incorrect
1.2.4
Keyword-Driven Testing
This requires the
development of data tables and keywords, independent of the test automation
tool used to execute them and the test script code that "drives" the
application-under-test and the data. Keyword-driven tests look very similar to
manual test cases. In a keyword-driven test, the functionality of the
application-under-test is documented in a table as well as in step-by-step
instructions for each test. In this method, the entire process is data-driven,
including functionality.
1.2.4.1
Example
In order to open a window,
the following table is devised, and it can be used for any other application,
just it requires just changing the window name.
Test Table for Opening a Window
Window
|
Control
|
Action
|
Arguments
|
Window Name
|
Menu
|
Click
|
File, Open
|
Window Name
|
Menu
|
Click
|
Close
|
Window Name
|
Pushbutton
|
Click
|
Folder Name
|
Window Name
|
Verify
|
Results
|
Once creating the test
tables, a driver script or a set of scripts is written that reads in each step
executes the step based on the keyword contained the Action field, performs
error checking, and logs any relevant information.
1.2.4.2
Merits of keyword driven testing
The merits of the Keyword
Driven Testing are as follows,
Ø The Detail Test Plan can be
written in Spreadsheet format containing all input and verification data.
Ø If "utility"
scripts can be created by someone proficient in the automated tool’s Scripting
language prior to the Detail Test Plan being written, then the tester can use
the Automated Test Tool immediately via the "spreadsheet-input" method,
without needing to learn the Scripting language.
Ø The tester need only learn
the "Key Words" required, and the specific format to use within the
Test Plan. This allows the tester to be productive with the test tool very
quickly, and allows more extensive training in the test tool to be scheduled at
a more convenient time.
1.2.4.3
Demerits of keyword driven testing
The demerits of the Keyword
Driven Testing are as follows,
Ø Development of
"customized" (Application-Specific) Functions and Utilities requires
proficiency in the tool’s Scripting language. (Note that this is also true for
any method)
Ø If application requires
more than a few "customized" Utilities, this will require the tester
to learn a number of "Key Words" and special formats. This can be
Ø time-consuming, and may have
an initial impact on Test Plan Development. Once the testers get used to this,
however, the time required to produce a test case is greatly improved.
1.2.5 Hybrid
Test Automation Framework
The most commonly
implemented framework is a combination of all of the above techniques, pulling
from their strengths and trying to mitigate their weaknesses. This hybrid test
automation framework is what most frameworks evolve into over time and multiple
projects. The most successful automation frameworks generally accommodate both
Keyword-Driven testing as well as Data-Driven scripts.
This allows data driven
scripts to take advantage of the powerful libraries and utilities that usually
accompany a keyword driven architecture. The framework utilities can make the
data driven scripts more compact and less prone to failure than they otherwise
would have been.
The utilities can also
facilitate the gradual and manageable conversion of existing scripts to keyword
driven equivalents when and where that appears desirable. On the other hand,
the framework can use scripts to perform some tasks that might be too difficult
to re-implement in a pure keyword driven approach, or where the keyword driven
capabilities are not yet in place. The following sections describe its
architecture, merits and demerits.
1.2.5.1
Hybrid Test Automation Framework Architecture
The framework is defined by
the Core Data Driven Engine, the Component Functions, and the Support
Libraries. While the Support Libraries provide generic routines useful even
outside the context of a keyword driven framework, the core engine and
component functions are highly dependent on the existence of all three
elements.
The test execution starts
with the LAUNCH TEST(1) script. This script invokes the Core Data Driven Engine
by providing one or more High-Level Test Tables to CycleDriver(2). CycleDriver
processes these test tables invoking the SuiteDriver(3) for each
Intermediate-Level Test Table it encounters. SuiteDriver processes these
intermediate-level tables invoking StepDriver(4) for each Low-Level Test Table
it encounters. As StepDriver processes these low-level tables it attempts to
keep the application in synch with the test. When StepDriver encounters a low-level
command for a specific component, it determines what Type of component is
involved and invokes the corresponding Component Function(5) module to handle
the task.
All of these elements of
the framework rely on the information provided in the App Map to interface or
bridge the automation framework with the application being tested. The App Map
is the only means by which the framework could identify the objects in the
application under test. Each of these elements is described in more detail in
the following sections. The following figure shows the diagrammatic
representation of the Hybrid Test Automation Framework.
APPLICATION
MAP
The Application Map is one
of the most critical components, which is used for mapping the objects from
names humans can recognize to a data format useful for the automation tool. For
a given project it is needed to define a naming convention or specific names
for each component in each window as well as a name for the window itself. Then
use the Application Map to associate that name to the identification method
needed by the automation tool to locate and properly manipulate the correct
object in the window.
Application Map not only
gives the ability to provide useful names for the objects, it also enables the
scripts and keyword driven tests to have a single point of maintenance on the
object identification strings. Thus, if a new version of an application changes
the title of the window or label of the components or the index of an image
element within it, they should not affect the test tables. The changes will
require only a quick modification in one place--inside the Application Map.
COMPONENT
FUNCTIONS
Component Functions are
those functions that actively manipulate or interrogate component objects. In
test automation framework there are different Component Function modules for
each type of component that are encountered (Window, CheckBox, TextBox, Image,
Link, etc,).
Component Function modules
are the application-independent extensions applied to the functions already provided
by the automation tool. However, unlike those provided by the tool, the extra
code to help with error detection, error correction, and synchronization are
added. These modules can readily use the application-specific data stored in
the Application Map and test tables as necessary. In this way, these Component
Functions are developed once and are used again and again by every application
tested.
Another benefit from
Component Functions is that they provide a layer of insulation between the
application and the automation tool. Without this extra layer, changes or
"enhancements" in the automation tool itself can break existing
scripts and the table driven tests. Each Component Function modules will define
the keywords or "action words" that are valid for the particular
component type it handles.
The component Functions
takes the windows name in which the component resides, the actual component
name on which the action is to be performed, the values needed for performing
the action and the type of action to be performed as its arguments. The
Component Function keywords and their arguments define the low-level vocabulary
and individual record formats will be used to develop the test tables.
TEST TABLES
The input to the framework apart from the application
map are the test tables, which holds the arguments needed for the Component
Functions and other information. There are three levels in which the test
tables are organized, they are as follows,
Ø Low-Level Test Tables (or)
Step Tables
Ø Intermediate-Level Test
Tables (or) Suite Tables
Ø High-Level Test Tables (or)
Cycle Tables.
LOW-LEVEL
TEST TABLES
Low-level Test Tables or
Step Tables contain the detailed step-by-step instructions of the tests. Using
the object names found in the Application Map, and the vocabulary defined by
the Component Functions; these tables specify what window, what component, and
what action to take on the component. The columns in the Step Tables are as
follows,
Ø Action Command
Ø Window Name
Ø Component Name
Ø Values Need to Perform the
Specified Action
The StepDriver module is
the one that initially parses and routes all low-level instructions that
ultimately drive our application.
INTERMEDIATE-LEVEL
TEST TABLES
Intermediate-level Test
Tables or Suite Tables do not normally contain such low-level instructions.
Instead, these tables typically combine Step Tables into Suites in order to
perform more useful tasks. The same Step Tables may be used in many Suites. In
this way the minimum numbers of Step Tables necessary are developed. Then they
are organized in Suites according to the purpose and design of the tests, for
maximum reusability. The columns in the Suite Tables are as follows,
Ø Step Table Name
Ø Specific Arguments to be
Passed to the Step Tables
The Suite Tables are
handled by the SuiteDriver module which parses each record in the Suite Table
and passes each Step Table to the StepDriver module for processing.
HIGHER-LEVEL
TEST TABLES
High-level Test Tables or Cycle Tables combine
intermediate-level Suites into Cycles.
The Suites can be combined in different ways
depending upon the testing Cycle which is efficient to execute. Each Cycle will
likely specify a different type or number of tests. The columns in the Cycle
Tables are as follows,
Ø Suite Table Name
Ø Specific Arguments to be
Passed to the Suite Table
These Cycles are handled by
the CycleDriver module which passes each Suite to SuiteDriver for processing.
CORE DATA
DRIVEN ENGINE
The Core Data Driven Engine
is the primary part of the framework and it has three main modules, they are as
follows
Ø StepDriver
Ø SuiteDriver
Ø CycleDriver
CycleDriver processes
Cycles, which are high-level tables listing Suites of tests to execute.
CycleDriver reads each record from the Cycle Table, passing SuiteDriver each
Suite Table it finds during this process. SuiteDriver processes these Suites,
which are intermediate-level tables listing Step Tables to execute. SuiteDriver
reads each record from the Suite Table, passing StepDriver each Step Table it
finds during this process. The following figure represents the Core Data Driven
Engine,
StepDriver processes these
Step Tables, which are records of low-level instructions developed in the
keyword vocabulary of the Component Functions. StepDriver parses these records
and performs some initial error detection, correction, and synchronization
making certain that the window and\or the component planned to manipulate is
available and active. StepDriver then routes the complete instruction record to
the appropriate Component Function for final execution.
SUPPORT LIBRARIES
The Support Libraries are
the general-purpose routines and utilities that let the overall automation
framework do what it needs to do. They are the modules that provide services
like,
Ø File Handling
Ø String Handling
Ø Buffer Handling
Ø Variable Handling
Ø Database Access
Ø Logging Utilities
Ø System\Environment Handling
Ø Application Mapping
Functions
Ø System Messaging or System
API Enhancements and Wrappers
They also provide
traditional automation tool scripts access to the features of our automation
framework including the Application Map functions and the keyword driven engine
itself. Both of these items can vastly improve the reliability and robustness
of these scripts until such time that they can be converted over to keyword
driven test tables.
CHECK POINTS
A checkpoint verifies that
expected information is displayed in a Application while the test is running.
The expected information is captured while creating the check points and is
compared against the data from the Application on runtime
When to go for Check Points in
the test
Check points are mainly used when the objective is to compare certain
object against the earlier captured Expected value (While recording/Creating
Check Points),
The Check Points should be used
when the Object in test (Table, Text etc) is static and stationary and the
output can be predicted.
When to Use Different Check
Points
a. Standard Check Point:
a. When Different object properties are to be verified (e.g. To check if a check box is selected or not)
b. Text Check point
a. To check if a text String is displayed at an appropriate location on the Page
c. Text Area Check Points
a. To verify the Text values of an object.
d. Bitmap Check Points
a. When an area on the Application is to be checked as Bitmap image
e. Page Check Points:
a. To check the properties of a page, Broken Links on the Page, Load Time.
f. Image Check Points:
a. To check if an Image is displayed on the application or not (e.g. Company Logo)
g. Table Check Points
a. To check the contents of a Table in the Application
h. Database Check Points:
a. Checks the DB contents by Querying the DB
i. XML Check Points:
a. Checks an XML documents within a Web Page/Frame OR Checks a specified XML file
j. Accessibility Checkpoint
a. To check Frames, applets, Active X and Alt property of an image from a Webpage.
Environments Supported by
Different Check Points
a. Standard (Object) Check Points: Works with all the Add-in Environment
b. Page Check Points: Works on Web Environment
c. Image Check Points : Supported on Web Environment
d. Bitmap Check Points: Works with all the Add-in Environment
e. Text Check Points: Supported on all Environments
f. Table Check Points: Supported on Web and Active X Environments
g. DB Check Points: Supported on all the Environments supported by QTP
h. XML Check Points: XML check points are only available when Web Add-ins are installed and loaded.
i. Accessibility Check Points: Web Environment.
You can add accessibility checkpoints to help you quickly identify areas of your Web site that may not conform to the W3C Web Content Accessibility Guidelines.
j. These guidelines are developed by the W3C (World Wide Web Consortium) to develop uniform access criteria for Web-Based technologies.
NOTE: Some of the Check Points support Additional Add-in Environments which might need to be installed externally.
Regular Expressions in Check
Points
If the Value set in the Check Point is Dynamic in Nature and expected to change during the Run-time, Regular Expressions can be used alongwith the Check Points to handle this scenario.
For E.g.
If user creates a check point at a Page Description which has only a part of it as static and rest of the description is dynamic in nature ( abc-…..)
User can define a regular expression for all the text which is dynamic in nature
NOTE: Regular Expression are advisable only when Some part of the text is Static and other is dynamic( Changes on the Runtime) in nature so that the dynamic text can be replaced with a regular Expression.
QTP provides various options that can be used with regular expression to enhance the efficiency of the search string as mentioned in the table below
.
|
Matching
Any Single Character
|
[xy]
|
Matching
Any Single Character in a List
|
[^xy]
|
Matching
Any Single Character Not in a List
|
[x-y]
|
Matching
Any Single Character within a Range
|
*
|
Matching
Zero or More Specific Characters
|
+
|
Matching
One or More Specific Characters
|
?
|
Matching
Zero or One Specific Character
|
(
)
|
Grouping
Regular Expressions
|
|
|
Matching
One of Several Regular Expressions
|
^
|
Matching
the Beginning of a Line
|
$
|
Matching
the End of a Line
|
\w
|
Matching
Any Alpha Numeric Character Including the Underscore
|
\W
|
Matching
Any Non-Alpha Numeric Character
|
You can combine regular expression operators in a single expression to achieve the exact search criteria you need.
Different Coding Alternatives
which can be used instead of Check Points
Check
Points
|
Alternate
VB Script Code (On Web Environment)
|
Text
CheckPoint
|
Browser("..").Page("..").WebElement("..").Exist
|
Image
CheckPoint
|
Browser("..").Page("..").Image("…").Exist
|
Standard
Check Point
|
IF
Browser("..").Page("..").WebcheckBox("..").Set
"ON"
|
Table CheckPoint
|
IF
Browser("..").Page("..").WebTable("..").Exist
|
DataBase
CheckPoint
|
Create
a DB Object in the QTP Script
|
Output Values
The Values from the Application can be retrieved and stored as Output values
These output values can be passed to the Data table or to Environment variable and can then be used at different stage in the script.
Different Types of Output check Points
a. Standard Output values – Supported on All the Environments
b. Text Output Values – Supported on all the Environments
c. Text Area Output Values – Not supported on the Web Environment
d. Data Base Output Values
e. XML Output Values
f. Table Output Values
g. Page Output Values – Supported on Web Environment
Some Additional Options can be
used with Check Points
a. User can set the default Synchronization Time out for the check Points
b. (By Default, the Check Point Time out is 0 Seconds)
c. While creating Check Points, User can select which Properties to select from the list of the properties QTP identifies
d. QTP 9.0 provides options to change the default properties of the object under test
e. Check Points can also be parameterized to compare the object in the Application against the Data Table or can be compared against an Environment variable as well.
'To hide or unhide files from a folder
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You need to make use of GetFile method on
FileSystemObject and then set the value of "Attributes" property to
-1 to hide the file.
KeyBenefits
of QTP
1. Descriptive Programming Approach
2. Actions concept
3. Fast Execution
4. Better object identification mechanism.
5. Active Screen Feature
6. Data table Feature
7. Advanced Keyword Driven Approach
8. Easy to Use
LibraryFunctions
' ~~~~~~~~~~~~~~~~~~~ LibFlights.vbs
~~~~~~~~~~~~~~~~~~~~~~~~
' 1. OpenFlights()
' 2. Login(Agent, Pword)
' 3. NewOrder(dtFlight, FlyFrm, FlyTo,
FltDetails, Cname, Tkts)
' 4. OpenOrder(OrdNum)
' 5. UpdOrder(Cname, Tkts)
' 6. FaxOrder(FaxNum)
' 7. Logout()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Invoke
Function OpenFlights()
SystemUtil.Run
"C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program
Files\HP\QuickTest Professional\samples\flight\app\","open"
If
Dialog("Login").Exist Then
OpenFlights
= "Pass"
Else
OpenFlights
= "Fail"
End
If
End Function
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Function
Name :Login
' Parameters
' input
' output
' Return
Value
' Author :
' Date
' Location
' Module/Functionality
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision History
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision
By
' Date
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function Login(Agent, Pword)
Dialog("Login").WinEdit("Agent
Name:").Set Agent
Dialog("Login").WinEdit("Password:").Set
Pword
Dialog("Login").WinButton("OK").Click
If
Window("Flight Reservation").Exist Then
Login
= "Pass"
Else
Login
= "Fail"
End
If
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Function
Name :Insert
' Parameters
' input
' output
' Return
Value
' Author :
' Date
' Location
' Module/Functionality
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision History
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision
By
' Date
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function NewOrder(dtFlight, FlyFrm, FlyTo, FltDetails,
Cname, Tkts)
Window("Flight
Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight
Reservation").ActiveX("MaskEdBox").Type dtFlight
Window("Flight
Reservation").WinComboBox("Fly From:").Select FlyFrm
Window("Flight
Reservation").WinComboBox("Fly To:").Select FlyTo
Window("Flight
Reservation").WinButton("FLIGHT").Click
Window("Flight
Reservation").Dialog("Flights
Table").WinList("From").Select FltDetails
Window("Flight
Reservation").Dialog("Flights
Table").WinButton("OK").Click
Window("Flight
Reservation").WinEdit("Name:").Set Cname
Window("Flight
Reservation").WinEdit("Tickets:").Set Tkts
Window("Flight
Reservation").WinButton("Insert Order").Click
wait(9)
t =
Window("Flight Reservation").WinEdit("Order
No:").GetROProperty("text")
NewOrder
= t
End Function
'Open
Function OpenOrder(OrdNum)
Window("Flight
Reservation").WinMenu("Menu").Select "File;Open
Order..."
Window("Flight
Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "ON"
Window("Flight
Reservation").Dialog("Open
Order").WinEdit("Edit_2").Set OrdNum
Window("Flight
Reservation").Dialog("Open
Order").WinButton("OK").Click
If
Window("Flight Reservation").Exist Then
OpenOrder
= "Pass"
Else
OpenOrder
= "Fail"
End
If
End Function
'Update
Function UpdOrder(Cname, Tkts)
Window("Flight
Reservation").WinEdit("Name:").Set Cname
Window("Flight Reservation").WinEdit("Tickets:").Set
Tkts
Window("Flight
Reservation").WinButton("Update Order").Click
End Function
'Fax
Function FaxOrder(FaxNum)
Window("Flight
Reservation").WinMenu("Menu").Select "File;Fax
Order..."
Window("Flight
Reservation").Dialog("Fax Order No. 6").ActiveX("MaskEdBox").Type
FaxNum
Window("Flight
Reservation").Dialog("Fax Order No.
6").WinButton("Send").Click
End Function
'Logout
Function Logout()
Window("Flight
Reservation").WinMenu("Menu").Select "File;Exit"
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~~~~~~~~~~~~~~~~~~~ LibFlights.vbs
~~~~~~~~~~~~~~~~~~~~~~~~
' 1. OpenFlights()
' 2. Login(Agent, Pword)
' 3. NewOrder(dtFlight, FlyFrm, FlyTo,
FltDetails, Cname, Tkts)
' 4. OpenOrder(OrdNum)
' 5. UpdOrder(Cname, Tkts)
' 6. FaxOrder(FaxNum)
' 7. Logout()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Invoke
Function OpenFlights()
SystemUtil.Run
"C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program
Files\HP\QuickTest Professional\samples\flight\app\","open"
End Function
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Function
Name :Login
' Parameters
' input
' output
' Return
Value
' Author :
' Date
' Location
' Module/Functionality
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision History
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision
By
' Date
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function Login(Agent, Pword)
Dialog("Login").WinEdit("Agent
Name:").Set Agent
Dialog("Login").WinEdit("Password:").Set
Pword
Dialog("Login").WinButton("OK").Click
End Function
'Insert
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Function
Name :Insert
' Parameters
' input
' output
' Return
Value
' Author :
' Date
' Location
' Module/Functionality
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision History
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Revision
By
' Date
' Description
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function NewOrder(dtFlight, FlyFrm, FlyTo, FltDetails,
Cname, Tkts)
Window("Flight
Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight
Reservation").ActiveX("MaskEdBox").Type dtFlight
Window("Flight
Reservation").WinComboBox("Fly From:").Select FlyFrm
Window("Flight
Reservation").WinComboBox("Fly To:").Select FlyTo
Window("Flight
Reservation").WinButton("FLIGHT").Click
Window("Flight
Reservation").Dialog("Flights Table").WinList("From").Select
FltDetails
Window("Flight
Reservation").Dialog("Flights
Table").WinButton("OK").Click
Window("Flight
Reservation").WinEdit("Name:").Set Cname
Window("Flight
Reservation").WinEdit("Tickets:").Set Tkts
Window("Flight
Reservation").WinButton("Insert Order").Click
End Function
'Open
Function OpenOrder(OrdNum)
Window("Flight
Reservation").WinMenu("Menu").Select "File;Open
Order..."
Window("Flight
Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "ON"
Window("Flight
Reservation").Dialog("Open
Order").WinEdit("Edit_2").Set OrdNum
Window("Flight
Reservation").Dialog("Open
Order").WinButton("OK").Click
End Function
'Update
Function UpdOrder(Cname, Tkts)
Window("Flight
Reservation").WinEdit("Name:").Set Cname
Window("Flight Reservation").WinEdit("Tickets:").Set
Tkts
Window("Flight
Reservation").WinButton("Update Order").Click
End Function
'Fax
Function FaxOrder(FaxNum)
Window("Flight
Reservation").WinMenu("Menu").Select "File;Fax
Order..."
Window("Flight
Reservation").Dialog("Fax Order No.
6").ActiveX("MaskEdBox").Type FaxNum
Window("Flight
Reservation").Dialog("Fax Order No.
6").WinButton("Send").Click
End Function
'Logout
Function Logout()
Window("Flight
Reservation").WinMenu("Menu").Select "File;Exit"
End Function
Naming
Conventions
A Naming Convention is a collection of rules followed
by a set of names. The intent is that users of these names will be able to
deduce useful information, based on the names' character sequence and knowledge
of the rules followed. Though naming conventions are difficult to follow, they
would be very useful during maintenance of the script.
Test Name
The Test
name should be with an acronym that represents the application and followed by
the Module Name that is being automated.
Example:
MSTodayHomePage would be the name of the Test Script automating homepage of MS
Today web portal.
Actions
The Action name should be with an acronym of the test
script name, Module name and the sub-module that is being automated.
Example:
MST_HP_Navigation would be the name of the Action, where MST is the acronym of
MS Today and HP the acronym of homepage. Navigation is the sub-module of
homepage.
Reusable Actions
The reusable Action name should be following the same
naming convention of Actions with only word “R” attached at the end.
Example:
MST_HP_Navigation_R would be the name of the Action, where MST is the acronym
of MS Today and HP the acronym of homepage. Navigation is the sub-module of
homepage.
Variables
The Variable name should be with an acronym of the
data type and the variable name.
Example:
chrName would be the name of the variable, where chr is the acronym of
character and Name is the entity.
Arrays
The array variables should be prefixed with “arr”
before the variable name.
Example:
arrName would be the name of the variable, where arr is the acronym for array
and Name is the entity.
Temporary Variables
The dummy variables which would be used in many places
across the action with different values can be declared with acronym “tmp” and
then the variable name.
Example:
tmpName would be the name of the variable, where tmp is the acronym for
Temporary variable and Name is the entity.
Functions
The Function name should be with an acronym “fcn” and
the name representing its purpose.
Example:
fcnCalculateTime would be the name of the function, where fcn is the acronym
for function and CalculateTime is the name representing the function purpose.
Function Variables
The Function Variable name should be with an acronym of
the data type and the variable name.
Example:
chrName would be the name of the variable, where chr is the acronym of
character and Name is the entity
<< Further these are the following
things which needs to be added>>
1.
Data Sheet
2.
Object Repository
3.
Recovery Files
4.
VBS files
Coding Standards
Action Template
All the action in the script would be in a standard
and specific format. The Action Template has five different sections in it.
Option
Explicit:
This would make sure
that all the variables have been declared in the Action.
Header:
The Header should
contain information like Action Name, Purpose of the Action, Number of
Verifications done in that particular action, Preconditions for the action
(like users id should exist etc…), Author of the Action, and the Creation date
of the action.
Declaring
Variables:
All the variables
should be declared under this section only, unless it a ReDim which could be
given wherever needed. It should also contain comments briefing the usage of
the variables.
Assigning
Variables:
If any default value
has to be assigned for a variable that should be done only in this section. The
variables may be reassigned thereafter in the script. Constant values
declaration also needs to be included under this section.
Main
Script:
Main part of the script
for functional verification or calling other actions should come under this
section.
Internal
Functions:
All the internal
functions used within the Action should be defined under this section only.
Review
History:
This section would have
an audit as who has reviewed the script on what date etc. It also has a field,
Comment which may have the comments of the person who reviewed the script.
Coding Techniques
·
The first letter of any scripting statement
should be in Upper case. Example, For…Next, Dim, If…Then..Else…End If etc…
·
The Wait statement should be called wherever
the script has to wait for the application to respond or refresh. The
performance of the application may vary for every build depending on various factors.
If in any of the future builds the application is slow and takes more time to
respond, it would be very difficult to and change the number of wait seconds
throughout the script.
Therefore to avoid this
rework, an environment variable, “numWait” should be created and the Wait
statement should be called as,
Call Wait (5 + numWait)
Whenever the
application is very slow and we wanted to increase the wait time, then the
value of the variable, numWait would be increased, which in turn would increase
the Wait time. This approach would be very helpful in long run.
·
Indentation should be proper. Unnecessary
spacing should be avoided.
·
There should be a comment line explaining
about all the logic formed in code.
·
There should be a space left between the
operators and the operands
Types of Parameters
~~~~~~~~~~~~~~~~~~~~
1. Environment Variables
2. Data Table
3. Random Number
4. Test/Action Parameters
Procedure to do Parameterization (Environment
Variables)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Create a XML file with Environment Variables
2. Associate the XML file to the Test.
File Menu
-> Settings -> environment -> Variable Type as -> User defined and
Seleect Load variables check box and browse the XML file
3. Open the script in Keyword view
4. Identify the object to perform parameterization
5. Select its value column
6. Click on "Configure the Value" button (which displayed after selecting the value column)
7. Select Parameter Radio button
Parameter
Type as -> Environment
Name
of the Variable in the Name field
8. Perform the same process to parameterize the other objects as test needs.
Procedure to do Parameterization (DataTable)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Create a XL file with test data.
2. Associate the XL file to the Test.
Select
DataTable (View Menu)
Right Click
on the Global sheet area
Select Sheet
-> Import -> From file and Browse the XL file
3. Open the script in Keyword view
4. Identify the object to perform parameterization
5. Select its value column
6. Click on "Configure the Value" button (which displayed
after selecting the value column)
7. Select Parameter Radio button
Parameter
Type as -> DataTable
Location
as -> global sheet
Name
-> Column Name
8. Perform the same process to parameterize the other
objects as test needs.
Procedure to do Parameterization (Random Number)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: Only numeric data we can parameterize
1.Open the script in Keyword view
2. Identify the object to perform parameterization
3. Select its value column
4. Click on "Configure the Value" button (which displayed
after selecting the value column)
5. Select Parameter Radio button
Parameter
Type as -> Random number
Enter
a Range ->
Name
-> Enter a Parameter Name
6. Perform the same process to parameterize the other objects as test needs.
Intrinsic Problems with Automated Testing
1. Automated Scripts Become Outdated by Frequent
Changes to the Application.
Unless scripted by a
self-disciplined group of testers who understand object-oriented principles, it
is likely the automated scripts will contain a lot of duplicated code. Imagine
having hundreds or even thousands of automated scripts written against a word
processor. It is highly likely that those scripts will end up using several
features of the word processor just to arrive at the point being tested. Let's take
editing a file as an example. To test the underline feature, the application
must be started, a file must be opened, text must be selected, the underline
button must be pressed and finally the text must validated as being underlined.
This single test includes four actions; not to mention, validating the
successful completion of each of the actions. A change in any of these
application features necessitates changes in the underline test as well as many
other tests.
2. Flexibility and Power is often Sacrificed for Ease
of Scripting.
3. Automated Scripts are hard to Read and External
Docs Get Out of Sync.
4. Too Much Work to Test all Possible Scenarios.
In many cases, the data being
tested cannot be easily separated from the actual test script. This requires
creating several test scripts or requiring the data be included in the code
itselft in order to test the many small rules of a single business rule. This
not only requires extra work to test a that single feature, but it also makes
it a nightmare to maintain the test scripts that only differ in the data being
used to test the application.
5. Automated Scripts can be
Difficult to Port between Environments.
Many of the automated testing
frameworks available don't take the lifecycle of a product into consideration.
A product must go through development, alpha testing, beta testing, and
performance testing before it reaches the masses. Because of the infeasibility
of editing large numbers of scripts, many organizations only run their
automated tests against one environment, thus missing opportunities for
validation and regression testing as the application advances in the product
lifecycle.
6. Need to Learn Proprietary
Technologies.
Most testing tools require
learning a propriety language or technology. This makes it harder to find
experienced people, which restricts a company's options in selecting testing
tools. The narrow applicability of proprietary technologies may also deter
current employees from acquiring a more in-depth knowledge of the tool.
QTP 11.0 –
AIS Certification (Accredited Integration Specialist)
QTP 11 Version was introduced in September
2010, in July 2011 QTP 11 certification (Code: HPO-M47) has been introduced in
place of QTP 10.
Changes between QTP 10 and QTP 11 Certification Exams:
QTP 11 we just take one core exam that is HP AIS –Functional Testing (Code: HPO-M47) in formally known as QTP 11.0 certification.
Changes between QTP 10 and QTP 11 Certification Exams:
QTP 11 we just take one core exam that is HP AIS –Functional Testing (Code: HPO-M47) in formally known as QTP 11.0 certification.
QTP 11 Certification Exam Details:
o
Exam type: Objective (Multiple Choice)
o
Exam Duration: 105 Minutes
o
Number of Questions : 72
o
Pass percentage: 75%
Syllabus
for QTP 11 (HPO- M47) Certification Exam
SNO
|
Sections
|
Percentage
of Items
|
I)
|
Automated
Test Planning
|
10%
|
II)
|
Creating
Basic Tests and Working with Objects
|
19%
|
III)
|
Test
Verification & Enhancements
|
24%
|
IV)
|
Modular
automated test builds
|
11%
|
V)
|
QTP and
ALM integration
|
7%
|
VI)
|
Automated
test troubleshooting
|
10%
|
VII)
|
Advanced
QTP Scripting
|
4%
|
VIII)
|
Expert
View
|
7%
|
IX)
|
Web applications
|
8%
|
Detailed
Syllabus
I)
Automated Test Planning
o
Plan
for Test Automation.
o
Plan
for QTP testing.
o
Identify
and describe features and settings.
o
Explain
QTP licensing and packaging.
II)
Creating Basic Tests and Working with Objects
o
Create the basic test.
o
Explain how QTP works with objects.
o
Add steps without recording.
o
Object Identification Configuration and Smart Identification
III)
Test Verification & Enhancements
o
Add
Checkpoints
o
Enhance
tests with parameters.
o
Define
Test results
o
View
test results.
IV)
Modular automated test builds
o
Build Modular Tests using Actions
o
Using
Shared Object Repositories.
V)
QTP and ALM integration
o
Explain the QTP/ALM connection.
o
Define ALM management of QTP resources.
o
Explain
versioning features in QTP
VI)
Automated test troubleshooting
o
Troubleshoot Object Recognition problems.
o
Use Recovery scenarios.
o
Use the Debugging Tool.
o
Measure System Performance.
o
Configure
log tracking
VII)
Advanced QTP Scripting
o
Import and export Excel sheets.
o
Get and set object properties.
o
Using Programmatic Descriptions to bypass repository.
VIII)
Expert View
o
Features of Expert View
o
Describe dynamic object programming.
o
Identify
and describe VBScript elements.
IX)
Web applications
o
Recognize Web Add-in Extensibility.
o
Describe Web event recording use and configuration.
o
Identify
new web testing capabilities.
------------------------------------------------------------
Note: Maximum Questions on QTP Tool features only, Less
/ no importance for Scripting logic (VB Script). Industry point of view and
Product Understanding point view Certification is useful, but work point
limited use only.
In
order to get certification -
o
Explore all Tool Menus and remember QTP commands and Shortcut keys
o
Read HP QTP Documentation
o
Collect Exam papers dumps and Practice
o
Practice Tool features
------------------------------------------------------------------
' Read XML file contents
' ~~~~~~~~~~~~~~~~~~~~~
Dim objXML, Root, node
set objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = "false"
objXML.load("d:\myfile.xml")
Set Root = objXML.documentElement
For Each node In Root.childNodes
if
node.nodename="Variable" then
itemname=node.text
MsgBox
itemname
End
If
Next
set objXML = Nothing
Set Root = Nothing
' ~~~~~~~~~~~~~~~~~~~~~~~~~
' SendKeys method
' ~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim objKey
Set objKey = CreateObject("WScript.Shell")
Set objCalc=Window("nativeclass:=SciCalc",
"index:=0")
SystemUtil.Run "calc.exe"
wait (4)
objKey.AppActivate "Calculator"
objKey.SendKeys "2{+}"
wait(2)
objKey.SendKeys "2"
wait(2)
objKey.SendKeys "="
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Create a Word Document
' ~~~~~~~~~~~~~~~~~~~~~~~
Dim objWD
Set objWD = CreateObject("Word.Application")
objWD.Documents.Add
objWD.Selection.TypeText "Hello" &
Chr(13) & "How are you Doing"
objWD.ActiveDocument.SaveAs "D:\mydoc.doc"
objWD.Quit
Recording Scripts (Context Sensitive, Low Level and Analog)
There
are 3 types of recording modes in QTP.
i)
Context Sensitive
ii)
Low Level
iii)
Analog recording
QTP’s normal recording mode
records the objects on your application and the operations performed on them.
This mode is the default mode and takes full advantage of QTP's test object
model, recognizing the objects in your application regardless of their location on the screen.
When working with specific types
of objects or operations the user may need to use Analog Recording and Low-Level Recording.
Analog Recording – It enables
you to record the exact mouse and keyboard operations you perform in relation
to either the screen or the application window. In this recording mode, QTP
records and tracks every movement of the mouse as you drag the mouse around a
screen or window.
For example: Recording a
signature created by dragging the mouse.
The steps recorded using Analog Recording are saved in a
separate data file. This file is stored with the action or component in which
the analog steps are recorded.
Low-Level Recording – It enables
you to record on any object in your application, whether or not QTP recognizes
the specific object or the specific operation. This mode records at the object
level and records all run-time objects as Window or WinObject test objects.
Use low-level recording for recording
an object not recognized by QTP. You can also use low-level recording if the
exact coordinates of the object are important for your test or component.
Use Analog Recording or Low-Level
Recording only when QuickTest's normal recording mode does not
accurately record your operation
You can switch to either Analog Recording or Low-Level Recording in the middle of a
recording session for specific steps. Once you have recorded the necessary
steps in Analog Recording or Low-Level Recording, you can return to
normal recording mode for the remainder of your recording session.
Recovery Scenarios
What is a recovery scenario:
u Recovery scenario - a definition of an
unexpected event or error or application crash
and the operation(s) necessary to recover the run session
u A recovery scenario consists of the following:
Ø Trigger Event—The
event that interrupts your run session
Ø Recovery Operation(s)—The operation(s) that need to be performed in order
to continue running the test or component
Ø Post-Recovery Test Run Option—The instructions on how QuickTest should proceed once
the recovery operations have been performed, and from which point in the test
or component QuickTest should continue, if at all.
Recommendations
for using Recovery Scenarios
Ø
If you can
predict that a certain event may happen at a specific point in your component, it is highly recommended to handle that
event directly within your component by adding steps such as If statements or “Optional
Steps” in user-defined functions, rather than depending on a recovery
scenario.
Ø You should use recovery scenarios only for unpredictable events, or events that
you cannot synchronize with a specific step in your component.
Ø Handling an event directly within your
component enables you to handle errors more specifically than recovery
scenarios. It also enables you to control the timing of the corrective
operation with minimal resource usage and maximum performance.
1
2
3
4
5
6
7
Different Recovery
Operations:
- Keyboard or mouse
operation—QuickTest simulates a
click on a button in a window or a press of a keyboard key.
- Function Call - QuickTest calls a VBScript function.
- Close application process—QuickTest closes specified processes.
- Restart Microsoft Windows—QuickTest restarts Microsoft Windows.
Disclaimer: If you use the Restart Microsoft Windows
recovery operation, you must ensure that any component associated with this
recovery scenario is saved before you run it. You must also configure the
computer on which the component is run to automatically log in on restart.
Disclaimer: If you use the Function call recovery
operation, User can select an existing function from a library file or he can
define a new function. The new function is added to the function library you
selected.
8
Different Post-Recovery Test Run Options:
Disclaimer: If you are using the On error activation
option for recovery scenarios, the step that returns the error is often one or
more steps later than the step that caused the trigger event to occur. Thus, in most cases, repeating the current step does not
repeat the trigger event.
Disclaimer: Keep in mind that skipping a step that
performs operations on your application may cause subsequent steps to fail.
Disclaimer: If you chose Restart Microsoft Windows as
a recovery operation, you can choose from only the last two test run options
listed above.
Associating Recovery Scenarios with the test:
Ø While associating the recovery with your
test, you need to specify when you want to activate recovery scenarios i.e. only on errors or on every steps.
Ø If you select On errors option then keep in mind that by default, recovery
operations will be activated only when a step returns an error, which can
potentially occur several steps after the one that actually caused the error.
So you may get the advantages of using recovery scenarios.
Disclaimer: If you are using “On Error Resume Next”
statement in a script which has some activated Recovery scenarios then keep in
mind that “On Error Resume Next” is NOT going
to affect the triggering of Recovery Scenario i.e. Recovery Scenarios has
priority over “On Error Resume Next”.
Ø If you select on every steps then keep in mind that checking for trigger events
after every step, may slow performance.
Disclaimer: In this case, use “Recovery Object” which
enables you to control the recovery scenario mechanism programmatically during
the run session. “Activate Method” is an useful method associated with Recovery
Object which explicitly
activates the recovery scenario mechanism at a specific point in the run.
Activating recovery scenarios in particular section of the script, where the
probability of unexpected event or error or application crash is high, can
improve performance.
ScriptforScrollBarmoves
'For page up
Set
Obj=Browser("browsername").Page("pagename").Object.body
Obj.doScroll("pageUp")
'For page down
Set
Obj=Browser("browsername").Page("pagename").Object.body
Obj.doScroll("pageDown")
Or you can also the following Send Keys method: 'For
page up Set
objShell=CreateObject("WScript.Shell")
objShell.SendKeys "{PGUP}"
'For page down
Set objShell=CreateObject("WScript.Shell")
objShell.SendKeys "{PGDN}"
SendMail to OutLook
Set objLook =
CreateObject("OutLook.Application")
Set objMail = ObjLook.CreateItem(0)
objMail.Subject = "Test Result"
objMail.To = "mailid"
'objMail.cc = "mail ids"
objMail.Attachments.Add
"D:\SuryaQTP\Vbscript.doc"
objMail.HtmlBody = "Test Message"
objMail.send
Set objLook = Nothing
Synchronization Points
Synchronization points are used
if you do not want QTP to proceed/perform a step or checkpoint until an object
in your application achieves a certain status, you should insert a
synchronization point to instruct QTP to pause the test or component until the
object property achieves the value you specify.
Difference between synchronization point and
wait
If we use wait() method in our
script, QTP will compulsorily wait
there for the specified period of the time even if the object gets downloaded
on the application and then will proceed to the next step. Whereas in
synchronization point we specify the Timeout (in milliseconds) which is the maximum time for which QTP will wait and
then proceed. Hence, synchronization point saves the time for running the
script.
QTP must be able to identify the
specified object in order to perform a synchronization point. To instruct QTP
to wait for an object to open or appear, use an Exist or Wait
statement.
You can enter Exist and/or
Wait statements to instruct QTP to wait for a window to open or an
object to appear. Exist statements return a Boolean value indicating whether or
not an object currently exists. Wait statements instruct QTP to wait a
specified amount of time before proceeding to the next step. You can combine
these statements within a loop to instruct QTP to wait until the object exists
before continuing with the test or component.
If we use wait() method in our
script, QTP will compulsorily wait
there for the specified period of the time even if the object gets downloaded
on the application which slows down the
execution of the script. Whereas in Exist
method, QTP will wait until the object exist on the application which increases
the speed of execution.
We can use Exist method without specifying the time with it.
Eg: Window (“Window Name”).Dialog
(“Dialog Name”).Exist
In this case, QTP will wait maximum for the time, which is specified
in Timeout.
Similarly, we can use Exist method with time.
Eg: Window (“Window Name”).Dialog
(“Dialog Name”).Exist(5)
In this
case, QTP will wait maximum for the
specified amount of time with Exist method (5 seconds) irrespective of the time
specified in Timeout.
While automating the application,
the user is not sure about the time taken by the application to get downloaded
on the page. In that case synchronization point can be used which can save the
time of the execution.
To insert a
synchronization point:
- Begin recording your test
or component.
- Display the screen or
page in your application that contains the object for which you want to
insert a synchronization point.
- In QuickTest, choose Insert
> Step > Synchronization Point. The mouse pointer turns into a
pointing hand.
- Click the object in your
application for which you want to insert a synchronization point.
- Displays the dialog box showing the parent object
hierarchy of the selected object.
- Select the object for which you want to insert a
synchronization point, and click OK.
- The Add Synchronization Point dialog box opens
The Add Synchronization Point
dialog box contains the following options:
Property
name—Contains a list of the test
object properties associated with the object. Select the property name you want
to use for the synchronization point.
Property
value—Enables you to specify the
property value for which QuickTest should wait before continuing to the next
step in the test or component.
Timeout (in
milliseconds)—Enables you
to specify the time (in milliseconds) after which QuickTest should continue to
the next step, even if the specified property value was not achieved.
- Select the property name you want to use for the
synchronization point from the drop down.
- Enter the property value for which QTP should
wait before continuing to the next step in the test.
- Enter the synchronization point timeout (in
milliseconds) after which QTP should continue to the next step. After the
specified time (in Timeout), QTP will proceed to the next step even if the
specified property value was not achieved.
- Click OK.
A WaitProperty step is added to your test
or component with the Property name, Property value and Timeout (in
milliseconds).
Test Settings
Before
Running or Recording any test on QTP, the test settings need to be set as per
the requirements of the Test. Settings these Test Settings before starting a
Test plays a crucial part in the behaviour of the test.
These
can be found under File>Settings or the Settings toolbar button. A dialog
box opens, in which various tabs are present which allow one to set
- Properties of the test
- Run session preferences
- Resources to associate with test such as function libraries and
data table
- Parameters to specify( input and output) for test
- Environment variables( built-in and user-defined)
- Web for recording and running on a web browser
- Recovery for recovering from unexpected events and errors
Apart
from these tabs, it may contain other tabs corresponding to any external
add-ins that are loaded.
Run
This
consist of various options to set
- Data Tables iterations for the test
- How to respond when an error occurs during the run
session
- Object synchronization timeout
- Disable Smart Identification
- Capturing a snapshot of the desktop if an error occurs
during a run session
Disclaimer:
- Set the Data Table iterations to run one iteration only if one can handle it programmatically.
Otherwise leave it to default setting i.e. run on all rows
- If selecting run
from row m to row n, make sure that no blank row
selected
- Disable smart identification only if not needed
- While capturing image, set its extension to .png for
better performance
Resources
This
includes the following option areas:
- Function libraries to add, delete and prioritize which
associated with test
- Setting current list of function libraries as the
default
- Checking the syntax of library files
- Setting the location of the Data table
Disclaimer:
·
Associate library files which
are common to test
·
Specify the location of the
Data Table to Default location if it is action specific otherwise other
location to use it across the test.
Parameters
The
Parameters tab contains two lists:
- Input parameter pass values into test
- Output parameter pass values from test to external
sources
Disclaimer:
·
Specify input parameters if
test needs input from outside and
·
Specify output parameters if
test returning value.
Environment
This
displays existing built-in and user defined variables.
Disclaimer:
- Leave it to default setting i.e. built-in otherwise
change it user-defined and define parameters.
Web
It
provides for recording and running tests( only when web add-ins installed and
loaded) on web sites.
Recovery
This
displays a list of all recovery scenarios associated with the test and enables
to add, remove, change and view a read-only summary of each scenario.
Disclaimer:
- Always associate recovery scenarios with the test and
activate it on occurrence of an error.
- Always provide scenario description for associated
scenario with the test.
Excel File Operations
--------------------------------------------------
Objects in Excel Object Model
a) Excel Application
- Excel Application Object
b) Excel Workbook
/ File - Workbook Object
c) Excel Worksheet / sheet
- Worksheet Object
------------------------------------------------------
Note: Without creating Work Book Object and
Work Sheet Object, we can perform all Excel
Application Operations using Excel Application(Main) Object, but for user
friendliness we use those objects.
'Creating Excel Application Object
Dim objExcel
Set objExcel=CreateObject("Excel.Application")
Important Operations on Excel files
a) Create Excel Files
b) Open Excel Files
c) Read Data
d) Read Data for Data driven Testing
e) Write Data
f) Write Test Result
Examples:
---------------------------------------------
1) 'Create Excel file /Work book
Dim objExcel
Set objExcel=CreateObject("Excel.Application")
objExcel.Visible=True 'To view the Operations
objExcel.Workbooks.Add 'Creatining Excel file / workbook
objExcel.ActiveWorkbook.SaveAs "C:\Documents and Settings\Administrator\Desktop\myfile.xls"
objExcel.Quit 'To Quit the Excel Application
Set objExcel=Nothing
2) 'Check the existence of the File If
exists then open the file and enter some data
' If Not exists Create the
Excel file /Work book and enter some data
Dim objExcel, objFso, FilePath
FilePath = "C:\Documents and
Settings\Administrator\Desktop\Myfile.xls"
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objExcel = CreateObject("Excel.Application")
If objFso.FileExists(FilePath) Then
objExcel.Workbooks.Open
(FilePath)
objExcel.Worksheets("Sheet1").Cells(1,1)="VB Script"
objExcel.ActiveWorkbook.Save
Else
objExcel.Workbooks.Add
objExcel.ActiveSheet.Cells(2,2)="VB Script"
objExcel.ActiveWorkbook.SaveAs (Filepath)
End If
objExcel.Quit 'To Quit the Excel Appliction
Set objExcel=Nothing
------------------------------------------------------
3) 'Fetch Test Data directly from an Excel
file and perform Data driven testing Valid Login Operation
Dim objExcel, objWorkbook, objWorksheet
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\Documents and
Settings\Administrator\Desktop\Login.xls")
Set objWorksheet = objWorkbook.Worksheets("Sheet1")
RowsCount = objWorksheet.usedrange.rows.count
For I = 2 to RowsCount
SystemUtil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe
Dialog("Login").WinEdit("Agent Name:").Set
objWorksheet.Cells(i,"A")
Dialog("Login").WinEdit("Password:").Set
objWorksheet.Cells(i,"B")
Wait(1)
Dialog("Login").WinButton("OK").Click
If Window("Flight Reservation").Exist(5)
Then
Window("Flight Reservation").Close
objWorksheet.Cells(i,"C")="Login
Successful"
Else
SystemUtil.CloseDescendentProcesses
objWorksheet.Cells(i,"C")="Login
Filed"
End If
Window("Flight Reservation").Close
Next
objWorkbook.Save
objExcel.Quit
Set objWorksheet=Nothing
Set objWorkbook=Nothing
Set objExcel=Nothing
-------------------------------------------------------------------------
5) 'Capture Link names from Google home
page and export to Excel file 3rd sheet
Dim ObjExcel, ObjWorkbook, ObjWorksheet
Dim oLink, Links, myLink, i
Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook = ObjExcel.Workbooks.Open("C:\Documents and
Settings\Administrator\Desktop\GooglePageLinks.xls")
Set ObjWorksheet = ObjWorkbook.Worksheets(3)
ObjWorksheet.Cells(1,1)="Link Names"
Set oLink=Description.Create
oLink("micclass").value="Link"
Set
Links=Browser("title:=Google").Page("title:=Google").ChildObjects(oLink)
For i = 0 to Links.Count-1
myLink =
Links(i).GetRoProperty("text")
ObjWorksheet.Cells(i+2, 1) =
myLink
Next
ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing
----------------------------------------------------------------------------------
6) 'Capture Button names from Flight
Reservation Window (Flight Reservation Application) and export to Excel
file 3rd sheet
Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i
Set ObjExcel = CreateObject("Excel.Application")
Set ObjWorkbook = ObjExcel.Workbooks.Open("C:\Documents and
Settings\Administrator\Desktop\MainWindowButtonNames.xls")
Set ObjWorksheet = ObjWorkbook.Worksheets(2)
ObjWorksheet.Cells(1,1)
="Button Names"
Set oButton = Description.Create
oButton("Class Name").value="WinButton"
Set Buttons = Window("text:=Flight
Reservation").ChildObjects(oButton)
For I = 0 to Buttons.Count-1
myButton =
Buttons(i).GetRoProperty("text")
ObjWorksheet.Cells(i+2, 1) =
myButton
Next
ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing
-----------------------------------------------------------------------------------
7) ' Read/capture order numbers and
customer names from 1 - 10 orders in Flight Reservation window
Dim objExcel, objWorkBook, objWorkSheet, ord, CName
Set objExcel = createobject("Excel.Application")
Set objWorkBook = objExcel.Workbooks.Open("C:\Documents and
Settings\gcr\Desktop\Ordersdata.xls")
Set objWorkSheet = objWorkBook.Worksheets(2)
objWorkSheet.cells(1,1) = "Order No."
objWorkSheet.cells(1,2) = "CustName"
For ord= 1 to 10 Step 1
Window("Flight
Reservation").Activate
Window("Flight
Reservation").WinMenu(“Menu”).Select “File;Open Order…”
Window("Flight
Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "ON"
Window("Flight
Reservation").Dialog("Open Order").WinEdit("Edit").Set
ord
Window("Flight
Reservation").Dialog("Open
Order").WinButton("OK").Click
Wait 1
CName = Window("Flight
Reservation").WinEdit("Name:").GetROProperty("text")
objWorkSheet.cells(ord+1,1) = ord
objWorkSheet.cells(ord+1,2) = CName
Next
objWorkBook.Save
objExcel.Quit
Set objWorkSheet=Nothing
Set objWorkBook=Nothing
Set objExcel=Nothing
---------------------------------------------------------------------------------------
8) 'Create Excel file and Rename 1st sheet
as "Module", 2nd Sheet as "Test Case", 'and 3rd Sheet as
"Test Step"
Dim objExcel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Worksheets("Sheet1").Name = "Module"
Wait 4
objExcel.Worksheets("Sheet2").Name = "TestCase"
Wait 4
objExcel.Worksheets("Sheet3").Name = "TestStep"
objExcel.ActiveWorkbook.SaveAs "C:\Documents and
Settings\Administrator\Desktop\RenameSheets.xls"
objExcel.Quit
Set objExcel=Nothing
Excel File Operations
--------------------------------------------------
Objects in Excel Object Model
a) Excel Application
- Excel Application Object
b) Excel Workbook
/ File - Workbook Object
c) Excel Worksheet /
sheet - Worksheet Object
------------------------------------------------------
Note: Without creating Work Book Object and
Work Sheet Object, we can perform all Excel
Application Operations using Excel Application(Main) Object, but for user
friendliness we use those objects.
'Creating Excel Application Object
Dim objExcel
Set objExcel=CreateObject("Excel.Application")
Important Operations on Excel files
a) Create Excel Files
b) Open Excel Files
c) Read Data
d) Read Data for Data driven Testing
e) Write Data
f) Write Test Result
Examples:
---------------------------------------------
1) 'Create Excel file /Work book
Dim objExcel
Set objExcel=CreateObject("Excel.Application")
objExcel.Visible=True 'To view the Operations
objExcel.Workbooks.Add 'Creatining Excel file / workbook
objExcel.ActiveWorkbook.SaveAs "C:\Documents and Settings\Administrator\Desktop\myfile.xls"
objExcel.Quit 'To Quit the Excel Application
Set objExcel=Nothing
2) 'Check the existence of the File If
exists then open the file and enter some data
' If Not exists Create the
Excel file /Work book and enter some data
Dim objExcel, objFso, FilePath
FilePath = "C:\Documents and
Settings\Administrator\Desktop\Myfile.xls"
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objExcel = CreateObject("Excel.Application")
If objFso.FileExists(FilePath) Then
objExcel.Workbooks.Open
(FilePath)
objExcel.Worksheets("Sheet1").Cells(1,1)="VB Script"
objExcel.ActiveWorkbook.Save
Else
objExcel.Workbooks.Add
objExcel.ActiveSheet.Cells(2,2)="VB Script"
objExcel.ActiveWorkbook.SaveAs (Filepath)
End If
objExcel.Quit 'To Quit the Excel Appliction
Set objExcel=Nothing
------------------------------------------------------
3) 'Fetch Test Data directly from an Excel
file and perform Data driven testing Valid Login Operation
Dim objExcel, objWorkbook, objWorksheet
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\Documents and
Settings\Administrator\Desktop\Login.xls")
Set objWorksheet = objWorkbook.Worksheets("Sheet1")
RowsCount = objWorksheet.usedrange.rows.count
For I = 2 to RowsCount
SystemUtil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe
Dialog("Login").WinEdit("Agent Name:").Set
objWorksheet.Cells(i,"A")
Dialog("Login").WinEdit("Password:").Set
objWorksheet.Cells(i,"B")
Wait(1)
Dialog("Login").WinButton("OK").Click
If Window("Flight Reservation").Exist(5)
Then
Window("Flight Reservation").Close
objWorksheet.Cells(i,"C")="Login
Successful"
Else
SystemUtil.CloseDescendentProcesses
objWorksheet.Cells(i,"C")="Login
Failed"
End If
Window("Flight Reservation").Close
Next
objWorkbook.Save
objExcel.Quit
Set objWorksheet=Nothing
Set objWorkbook=Nothing
Set objExcel=Nothing
-------------------------------------------------------------------------
5) 'Capture Link names from Google home
page and export to Excel file 3rd sheet
Dim ObjExcel, ObjWorkbook, ObjWorksheet
Dim oLink, Links, myLink, i
Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook = ObjExcel.Workbooks.Open("C:\Documents and
Settings\Administrator\Desktop\GooglePageLinks.xls")
Set ObjWorksheet = ObjWorkbook.Worksheets(3)
ObjWorksheet.Cells(1,1)="Link Names"
Set oLink=Description.Create
oLink("micclass").value="Link"
Set Links=Browser("title:=Google").Page("title:=Google").ChildObjects(oLink)
For i = 0 to Links.Count-1
myLink =
Links(i).GetRoProperty("text")
ObjWorksheet.Cells(i+2, 1) =
myLink
Next
ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing
----------------------------------------------------------------------------------
6) 'Capture Button names from Flight
Reservation Window (Flight Reservation Application) and export to Excel
file 3rd sheet
Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i
Set ObjExcel = CreateObject("Excel.Application")
Set ObjWorkbook = ObjExcel.Workbooks.Open("C:\Documents and
Settings\Administrator\Desktop\MainWindowButtonNames.xls")
Set ObjWorksheet = ObjWorkbook.Worksheets(2)
ObjWorksheet.Cells(1,1)
="Button Names"
Set oButton = Description.Create
oButton("Class Name").value="WinButton"
Set Buttons = Window("text:=Flight
Reservation").ChildObjects(oButton)
For I = 0 to Buttons.Count-1
myButton =
Buttons(i).GetRoProperty("text")
ObjWorksheet.Cells(i+2, 1) =
myButton
Next
ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing
-----------------------------------------------------------------------------------
7) ' Read/capture order numbers and
customer names from 1 - 10 orders in Flight Reservation window
Dim objExcel, objWorkBook, objWorkSheet, ord, CName
Set objExcel = createobject("Excel.Application")
Set objWorkBook = objExcel.Workbooks.Open("C:\Documents and
Settings\gcr\Desktop\Ordersdata.xls")
Set objWorkSheet = objWorkBook.Worksheets(2)
objWorkSheet.cells(1,1) = "Order No."
objWorkSheet.cells(1,2) = "CustName"
For ord= 1 to 10 Step 1
Window("Flight Reservation").Activate
Window("Flight
Reservation").WinMenu(“Menu”).Select “File;Open Order…”
Window("Flight
Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "ON"
Window("Flight
Reservation").Dialog("Open Order").WinEdit("Edit").Set
ord
Window("Flight
Reservation").Dialog("Open
Order").WinButton("OK").Click
Wait 1
CName = Window("Flight
Reservation").WinEdit("Name:").GetROProperty("text")
objWorkSheet.cells(ord+1,1) = ord
objWorkSheet.cells(ord+1,2) = CName
Next
objWorkBook.Save
objExcel.Quit
Set objWorkSheet=Nothing
Set objWorkBook=Nothing
Set objExcel=Nothing
---------------------------------------------------------------------------------------
8) 'Create Excel file and Rename 1st sheet
as "ProjectName", 2nd Sheet as "ModuleName", 'and 3rd Sheet
as "TestScenarios"
Dim objExcel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Worksheets("Sheet1").Name = " ProjectName "
Wait 4
objExcel.Worksheets("Sheet2").Name = " ModuleName "
Wait 4
objExcel.Worksheets("Sheet3").Name = " TestScenarios "
objExcel.ActiveWorkbook.SaveAs "C:\Documents and
Settings\Administrator\Desktop\RenameSheets.xls"
objExcel.Quit
Set objExcel=Nothing
What is Data
Type?
Data type is a categorization of identifying
one of various types of data, such as string, integer,
double, date or Boolean etc…
Implicit
& Explicit Data types:
Specifying Data types along with variable
names is called Explicit declaration of Data types.
Declaring Variables Without
specifying Data types is called Implicit declaration of variables.
VB Script Supports Implicit
declaration of variables only, doesn’t support Explicit declaration of Data
types.
VB Script
Data Type:
VB script has only data type called Variant, it can hold any type of data,
and based on usage of data it considers data sub types.
Example:
Dim x
X is a Variable and it can hold any type of data
(String, integer, double, date etc…)
X= “Surya” ‘String
type
X= 100 ‘Integer
X= 10.345 ‘Double
X=#10/10/2010# ‘Date
How to know Data sub
types:
Using VarType Function
we can get data sub type
VarType
Function
It returns a value indicating a subtype of a Variable
Example:
'Checking
Data sub types
-----------------------------
Dim x, y, z(3)
x="Mindq"
Msgbox VarType(x) '8
for String
x=500
Msgbox VarType(x) '
2 for Integer
x="400"
Msgbox VarType(x) '8
for String
x=199.123
Msgbox VarType(x) '5
for double
x="199.123"
Msgbox VarType(x) '8
for string
x=#10/10/2010#
Msgbox VarType(x) '7
for date
Set x
=CreateObject("Scripting.FileSystemObject")
Msgbox VarType(x) '9
for Automation Object
x=384322225
Msgbox VarType(x) ‘3
for Long integer
Msgbox VarType(z) ‘8204
for Array
Msgbox VarType(y) '0 for Empty / Uninitialized
-------------------------------------------------------------------------------------
Data sub
type and descriptions:
String:
It consists of any type of characters, maximum length
up to approximately 2 billion characters.
Boolean:
It Contains either True or False
(Logical Result)
Empty:
Uninitialized, Value
is 0 for numeric variables or a zero-length string ("") for string
variables.
Integer:
Contains integer in the range -32,768 to 32,767
Long Integer
Contains integer in the range -2,147,483,648 to
2,147,483,647
Double:
Contains a double-precision, floating-point number in the range -1.79769313486232E308 to
-4.94065645841247E-324 for negative values; 4.94065645841247E-324 to
1.79769313486232E308 for positive values.
Date:
Contains a number that represents a date between
January 1, 100 to December 31, 9999
Object:
Contains an object
Error:
Contains an error number
Null:
Contains no valid data
Etc…
------------------------------------------------------------------------------------
'Converting
the Data from one type to another
-----------------------------------------------
We use Conversion
Functions to convert the data from one type to another.
Whenever we read data using input devices, or from
files, or from Databases or from Application objects
then VB Script considers the data as string type data, we need to convert the
data in order to perform operations.
Dim x, y, Tickets, Price
'Read from Input Devices
x=InputBox("Enter a Value")
Msgbox VarType(x) '8 for String
x=Cint(x)
Msgbox VarType(x) '2 for Integer
y=InputBox("Enter a Value")
Msgbox VarType(y) '8 for String
y=Cdbl(y)
Msgbox VarType(y) '5 for double
'Read from Application Objects
Tickets = Window("Flight
Reservation").WinEdit("Tickets:").GetVisibleText()
Msgbox VarType(Tickets)'8
Tickets=Cint(Tickets)
Msgbox VarType(Tickets) '2
Price = Window("Flight
Reservation").WinEdit("Price:").GetVisibleText()
Msgbox VarType(Price) '8
Price=Cdbl(Price)
Msgbox VarType(Price) '5
----------------------------------------------------------------------
Example: 2
Dim a, b, c
a=”100”
Msgbox VarType(a) ‘ 8 for String
a=Cint(a)
Msgbox VarType(a) ‘2 for Integer
b=”100.345”
Msgbox VarType(b) ‘ 8 for String
b=Cdbl(b)
Msgbox VarType(b) ‘5 for Double
c=”Hyderabad”
Msgbox VarType(c) ‘8 for String
c=Cint(c)
Msgbox VarType(c) ‘Mismatch (Error)
Note: we
can’t convert alphabets as integer or double type data
Hi there, I found your site via Google even as looking for a similar topic, your website came up, it looks good. I have bookmarked it in my google bookmarks.
ReplyDeleteDaVinci Cosmotop Spin Oval Watercolor brush Size 24
Thank u
DeleteRead all the related Posts:
ReplyDelete64 Software Manual Testing Interview Questions
Answers To Common Job Interview Questions
Behavioral Questions In Interviews
Questions to Ask at an Interview