Você está na página 1de 204

QTP Training – Day 1

VBScript

Today’s Topics

» Introduction to Automation

» QTP Overview

» Create Test

» Recording Modes

» Run Tests and View Results


Introduction to Automation

Automation is the process of identifying functionality that is manually


tested and using some type of scripting language to create, run and
execute that same functionality without user intervention.
Why do we need Automation

Manual Testing
• Time Consuming
• Low reliability
• Human resources
• Coverage

Automation Testing
• Speed
• Repeatability
• Programmable
• Coverage
• Reliability
• Reusability
Which Test cases to Automate?

• Tests that need to be run for every build of the application


• Tests that use multiple data values for same actions
• Tests that required detailed information from application
• internals (e.g., SQL, GUI attributes)
• Identical tests that need to be executed using different
• browsers
Which Test cases not to automate

Usability Testing
• “How easy is the application to use?”
One time testing “ASAP” testing
• “We need to test Now!”
Ad hoc\random testing
• “Based on intuition and knowledge of application”
Features of QTP

» Preparing to Record
» Creating a Basic Test
» Working with Objects
» Using Synchronization
» Using Standard Checkpoints
» Using Parameters and Data-Driven Tests
» Using Multiple and Reusable Actions
» Adding Steps Without Recording
» Creating Tests on a Web Application
» Using Custom Checkpoints
» Using Database Checkpoints
» Object Repository Administration
» Object Recognition Problems and Solutions
» Using Recovery Scenarios
QTP Supported Environments
Add-ins supported by QTP

Add-Ins Supported in QTP


• .Net
• Web
• VB
• Java
• Oracle apps
• SAP
• PeopleSoft
• Siebel
• Terminal Emulators( Unix, Mainframes)
QTP Add-in Manager
Overall QuickTest Workflow
Prepare To Record
Application Under Test
Use Case: Create a Flight Reservation Order

Test Requirements
1. Create a new order.
2. Verify that the Insert done…. message appears, confirming that the
new order was successfully generated.
3. Document the order number in the test results.
4. Verify that multiple new orders can be created using different
departure and arrival cities.
Test Environment Requirements

» Check for stability in the application under test.


» Ensure that the test and tester have permissions to access the

» Database
» Host systems
» Input/output data.
» Execute the test case steps manually to determine the expected
results.
Determine the Data to be Used

» Interview the Subject Matter Expert (SME) to determine what is


valid and what is invalid data for your AUT.
» Determine the extreme ranges of input data.
» Decide what should happen when an invalid data is given as input
to the application.
Prepare to Automate a Test

• Determine the initial and end conditions of the test.


• Standardize naming conventions for tests.
Plan Initial and End Conditions
Ensure You Are Prepared

» Check for the stability of the AUT.


» Identify the testers who will create tests and test the AUT.
» Execute the test case steps manually.
» Check your data.
» Determine the initial and end conditions of the test.
» Standardize naming conventions.
Launch QuickTest Professional

1. Select the required add-ins.


2. Set the QuickTest Professional options.
3. Establish the record and run settings.
Add-in Manager
User Interface
Missing Resources, Information, and Debug
Viewer Panes
QuickTest Professional Toolbars
QuickTest Professional Options - General
QuickTest Professional Options - Active Screen
QuickTest Professional Options - Run
Record and Run Settings - Windows
Launch and Record on a Specified Application
Review Questions
Now answer these review questions.
1. What is the purpose of loading an add-in?
a) To help the performance of QuickTest Professional when it runs.
b) To restore the layout of the QuickTest window so that it displays the panes in
their default sizes and positions.
c) To enable QuickTest Professional to recognize objects in an AUT’s
development environment.
d) Both b and c.
Review Questions

2. What is the most appropriate Record and Run setting when you
expect that the Windows application will be already running on the
desktop when the test is starts?
a) Record and Run test on any open Windows-based application.
b) Record and Run on these applications (opened on session start).
c) Record and Run on applications opened via the desktop (by the Windows
shell).
d) None of the above.
Review Questions

3. As a best practice, why should you not select any add-in the Add-
In Manager?
4. Why do you select Allow Other Mercury Products To Run Tests
And Components?
Exercise: Preparing the Test Environment

» Part 1: Launch QuickTest Professional 9.0


» Part 2: Set QuickTest test options
Create Test

Record basic steps


Enhance steps
• Object Identification
• Parameterize tests
• Checkpoints
• Output Values
Create test • Parameterize Actions
• Customize Results
• Control Statements
Create Object Repository • Descriptive programming
• Execute DOS commands
• Define Functions
• VB Scripts
Script – Expert View
• Recovery Scenarios
• …
Recording Modes

Normal Recording

Analog Recording

Low Level Recording


Recording Modes

Normal Recording
• Default recording mode
• Records objects on application
• Operations performed on them
Recording Modes

Analog Recording
• Records exact mouse and key board operations
• Records every move of the mouse
• Used while recording operations that cannot be recorded at
Object Level
• Cannot edit steps within QTP
Recording Modes

Analog Recording

Screen

Desktop.RunAnalog "Track1"

Window

Window("Microsoft Internet Explorer").RunAnalog "Track2"


Recording Modes

Low Level Recording

• Record on any object whether or not QTP identifies those Objects


• Records all run-time objects as Window or WinObject
• Use while
• Objects are not recognized by QTP
• Exact object co-ordinates are important in test
• May not run correctly on all objects…
Low Level Recording

Example in Low Level Recording

Window("Microsoft Internet Explorer").WinObject("Internet


Explorer_Server").Click 564,263
Window("Microsoft Internet Explorer").WinObject("Internet
Explorer_Server").Type "mercury"
Window("Microsoft Internet Explorer").WinObject("Internet
Explorer_Server").Type micTab
Record a Test
Run a Test and Save Results
View Test Run
Save a Test
Compress Test Directory
Steps to View Test Results
View Test Results
Review Questions

Now answer these review questions.


1. When outlining your test steps, what do you need to implement to
ensure that the test can be reiterated?
a) Load the appropriate add-in.
b) Have all required applications running on the desktop.
c) Set initial and end conditions as part of the test.
2. What does the Export Test to Zip feature do?
3. What does the Missing Resources pane show?
4. How do you determine whether a test failed or passed?
Exercise: Creating a Basic Test

» Part 1: Set initial conditions


» Part 2: Record the business process
» Part 3: Save the test
» Part 4: Run the test
» Part 5: View results
QTP Training – Day 2
Topics

Today’s Topics

» Object Properties

» Object Repository

» Object Identification

» Synchronization

» Environment Variables
QuickTest Professional Workflow
An Overview of Object Oriented Programming

» An object consists of:


» Data that describes the object.
» Functions that can be performed on the object.

» The types of objects that are created are defined by classes.


» QuickTest is also object-oriented.
» QuickTest objects are defined by classes.
» Each class in QuickTest defines the properties and methods available
to its objects.
» Each object contains the actual values for the properties.
QuickTest Objects and Classes
Objects-Property/Value Pairs
Object Properties

Object Properties

Mandatory Assistive
Object Properties

Eg, WinEdit

Mandatory Assistive
attachedtext window id

nativeclass ….


Objects-Property/Value Pairs
Object Spy
Logical Name
Stored Test Objects
Open the Object Repository Dialog Box
Use Object Repository

You can use Object Repository to:


» Define a new test object.
» Change the assigned logical name.
» Highlight an object in the application under test.
» Locate an object in Object Repository.
» Update the properties of an object.
New Test Object
Define a New Test Object
Rename the Logical Name
Highlight Feature
Locate in Repository Feature
The Update from Application Feature
Compact View of Object Repository
Filter Action Objects
Types of Object Repository

Test objects can be stored in two types of object repositories—a shared object repository
and a local object repository. A shared object repository stores test objects in a file that
can be accessed by multiple tests (in read-only mode). A local object repository stores
objects in a file that is associated with one specific action, so that only that action can
access the stored objects.
Types of Object Repository

When you plan and create tests, you must consider how you want to store objects in your
test. You can have separate action repository for each action and stores the objects for
each action in its corresponding action repository or you can store all the objects in your
test in a common (shared) object repository file that can be used for multiple tests
Object Repository

When to Use Shared Object Repository :


• When testing several tests of the same application

• When you expect object properties in the application to change from


time to time

• When there’s regular work with multi-action tests


Object Repository

When to Use Local Repository :


• To create single action tests
• When you do not expect frequent properties within the test object
• When very few test correspond to a given application
Adding Objects to Object Repository

Adding Objects to Object Repository: When you record a test, Quick Test adds
each object on which you perform operation to object repository.
You also add objects to object repository while editing
your test.

There are various ways to add an object to the object


repository while editing a test
• Using the Add New Object option in the object repository dialog box, you can add any
object as a single object or a parent object, along with all its children
• Choose View/Add object option from the Active Screen
• Insert a step in your test for a selected object from the Active Screen
Adding Objects to Object Repository
Object Identification

Object Identification dialog box to set mandatory and assistive properties, to select the ordinal
identifier, and to specify whether you want to enable the Smart Identification mechanism for each test
object.
Any changes you make in the Object Identification dialog box have no effect on objects already added
to the object repository.
Review Questions

Now answer these review questions.


1. What is an object class?
2. What is the first step to change the logical name of an object
recorded by QuickTest?
a) View the test results.
b) Open the Object Repository.
c) View the documentation field in the KEYWORD VIEW.
Review Questions

2. What is Object Spy used for?


a) Add objects in Object Repository.
b) Update objects in Object Repository.
c) View the run-time and test object properties and methods.

d) Highlight objects in the application under test.


Exercise: Using Object Repository

» Part 1: Record a new order » Part 5: Use the Highlight feature


» Part 2: Open the Object Repository » Part 6: Use the Locate In
dialog box Repository feature
» Part 3: Change the logical name of » Part 7: Add a new object
an object
» Part 4: Use the Object Spy feature
QuickTest Professional Workflow
Understanding Synchronization
Some Visual Cues

Some of the visual cues include:


» A progress bar reaches 100% completion.
» A status message appears.
» A button becomes enabled.
» A window opens and is ready for data entry.
» A pop-up message appears in response to an operation.
Examine the Steps for Synchronization
Add a Synchronization Point While Recording
Object Synchronization
Environment Variables

The Environment tab of the Test Settings dialog box (File > Settings) displays
existing built-in and user-defined environment variables. It also enables you to
add, modify, or delete internal user-defined environment variables, save the
defined variables to an external .XML file, and retrieve them from a file.

The Environment tab includes the following options for the Variable type:
Built-in. Displays the built-in environment variables defined by QuickTest
Professional and their current values.
User-defined. Displays both internal and external user-defined environment
variables and their current values.

If you export your user-defined variables to an external .XML file, you can then use
the exported environment variable file with any other test.
Review Questions

Now answer these review questions.


1. What is the function of a synchronization point?
a) To update test data.
b) To provide more time for an object to process before
moving to the next step in a test.
c) To set an environment variable for an object
Review Questions

2. Consider a scenario where in QuickTest, the synchronization


timeout is set to 10 seconds and the global timeout is set to 10
seconds. However, the actual time taken by the object to be visible
is 25 seconds. How long will QuickTest wait for the synchronization
to take place?
a) 20 seconds
b) 25 seconds
c) 10 seconds
d) 35 seconds
Review Questions

3. QuickTest enables you to specify a synchronization point:


a) While recording a test.
b) After recording a test.
c) Both during and after recording.
QTP Training – Day 3
Topics

Today’s Topics

» Synchronization Point

» Environment Variables

» Standard Check Points

» Text Check Points

» Bitmap Check Points

» Accessibility Check Points

» XML Check Points

» Reporting in QTP
QuickTest Professional Workflow
Understanding Synchronization
Some Visual Cues

Some of the visual cues include:

» A progress bar reaches 100% completion.

» A status message appears.

» A button becomes enabled.

» A window opens and is ready for data entry.

» A pop-up message appears in response to an operation.


Examine the Steps for Synchronization
Add a Synchronization Point While Recording
Object Synchronization
Environment Variables

The Environment tab of the Test Settings dialog box (File > Settings) displays
existing built-in and user-defined environment variables. It also enables you to
add, modify, or delete internal user-defined environment variables, save the
defined variables to an external .XML file, and retrieve them from a file.

The Environment tab includes the following options for the Variable type:
Built-in. Displays the built-in environment variables defined by QuickTest
Professional and their current values.
User-defined. Displays both internal and external user-defined environment
variables and their current values.

If you export your user-defined variables to an external .XML file, you can then use
the exported environment variable file with any other test.
Review Questions

Now answer these review questions.


1. What is the function of a synchronization point?
a) To update test data.
b) To provide more time for an object to process before
moving to the next step in a test.
c) To set an environment variable for an object
Review Questions

2. Consider a scenario where in QuickTest, the synchronization


timeout is set to 10 seconds and the global timeout is set to 10
seconds. However, the actual time taken by the object to be visible
is 25 seconds. How long will QuickTest wait for the synchronization
to take place?
a) 20 seconds
b) 25 seconds
c) 10 seconds
d) 35 seconds
Review Questions

3. QuickTest enables you to specify a synchronization point:


a) While recording a test.
b) After recording a test.
c) Both during and after recording.
Exercise: Adding Synchronization

» Use Environment variable for username and password to login to the application
» Login to the fight reservation application
» Insert an Order
» Exit from File Reservation application
Use Sync points wherever required and use shared object repository
QuickTest Professional Workflow
Understanding Checkpoints

» A checkpoint is a specialized step that compares two values and


reports the result.
» QuickTest compares actual results from the test run with expected
results in the test plan.
» If the two values match, the checkpoint passes. Otherwise, the test
fails.
Using Checkpoints

You use a checkpoint to:


» Verify the state of an object.
» Confirm that an application performs as expected.
Visual Cues
Checkpoint Types
Standard Checkpoint
Inserting a Checkpoint During Recording
Insert a Checkpoint After Recording
Identifying a Failed Checkpoint
Using a Regular Expression
Some Regular Expressions

Expression Char Description


Period . Matches any single character
Asterisk * Matches zero to any number of occurrences
of the preceding character
Plus + Matches one to any number of occurrences
of the preceding character
Brackets [A-Z][a-z] Matches a range of characters
[0-9] Matches a range of numbers
\w Matches any alphanumeric character
including underscore
\W Matches any non-alphanumeric character

Digit \d Matches any digit


\d{4} Matches exactly four digits
Rename a Checkpoint
Text Checkpoint
Checks that Current Text with the Expected Text displayed in a Web page
Bitmap Checkpoint

• Checks an area of a Web page or application after capturing it as a


bitmap

• Check that a Web page (or any portion of it) is displayed as


expected.
Bitmap Checkpoint
XML Checkpoint

• Checks the data content of XML documents

• XML file checkpoints are used to check a specified XML file; XML
application checkpoints are used to check an XML document within
a Web page.
Accessibility Checkpoint
Check if the images on a Web page include ALT properties, required by the W3C Web
Content Accessibility Guidelines

Browser("Browser").Page("Yahoo! Mail_4").Check CheckPoint("Yahoo! Mail_4")


Reporting

Reports an event to the test results

Syntax
Reporter.ReportEvent EventStatus, ReportStepName, Details

Argument Type Description


Status of the report step:
0 or micPass: Causes the status of this step to be passed and sends the
specified message to the report.
1 or micFail: Causes the status of this step to be failed and sends the
Number or
EventStatus pre-defined specified message to the report. When this step runs, the test fails.
constant 2 or micDone: Sends a message to the report without affecting the
pass/fail status of the test.
3 or micWarning: Sends a warning message to the report, but does not
cause the test to stop running, and does not affect the pass/fail status of
the test.
ReportStepName String Name of the intended step in the report (object name).
Description of the report event. The string will be displayed in the step
Details String
details frame in the report.
Review Questions

Now answer these review questions.

1. What is a Standard checkpoint?


a) A mechanism to check the property of an object
b) An add-in
c) An object type
d) A parameter
Review Questions

2. How do you determine if a checkpoint is used in a test?


a) A check mark appears next to the step in the test results.
b) The Operation column of Keyword View lists the operation as
Check.
c) A check mark appears at each level of the Test Summary tree.
d) All of the above.
Review Questions

3. Why do you use regular expressions in your tests?


a) To set an object property.
b) To define a checkpoint that can accept a range of values.
c) To check that all add-ins are installed.
Exercise: Adding Checkpoints

» Part 1: Insert a standard » Part 5: Add a comment


checkpoint
» Part 6: Run the test
» Part 2: Check the test results
» Part 7: Modify and run the test
» Part 3: Modify the test
» Part 8: Fix the test
» Part 4: Record and open a Fax
Order test
QTP Training – Day 4
VBScript

Today’s Topics

• Describe and use parameter types.


• Insert an input parameter.
• Insert an output parameter.
• Parameterize a checkpoint.
• Evaluate results for iterative tests
QuickTest Professional Workflow
Parameter Types

» Input parameter
» Output parameter
» Random Number parameter
» Environment parameter
Input Parameters for Data-Driven Tests
Using Design-Time Data Table
Using a Global Data Sheet
Using a Local Data Sheet
Data Table Location
Replacing Static Data with Input Parameters
Setting the Parameter Value
Supplying Data to the Parameter
Setting the Number of Iterations
Test Results Iterations
Using Output Parameter
Inserting an Output Parameter While Recording
Inserting an Output Parameter After Recording
Reusing Output as Input
Parameterizing a Checkpoint
Parameterizing an Object Repository
Random Number Parameter
Environment Parameter
Run-Time Table After Playback
Review Questions

Now answer these review questions.


1. What is the purpose of the input parameter?
a) Creates a parameter standard
b) Sets a constant parameter value
c) Drives a variety of data values through a test
2. Where can you find the result of an output parameter?
a) Design-time Data Table
b) Run-time Data Table
c) The .usr file
d) The default.xls file
Review Questions

3. Should the test be in the Record mode to insert an output


parameter?

4. How can you make a checkpoint flexible?


a) Use the Object Properties dialog box
b) Create and insert a regular expression
c) Input data to the parameter using the design-time Data Table
d) Both b and c
Exercise: Using Parameters

» Part 1: Record a new order, add synchronization point, and a


checkpoint
» Part 2: Create an output parameter from Active Screen
» Part 3: Parameterize to accept input values
» Part 4: Run the test
» Part 5: Use a random number parameter
QTP Training – Day 5
Topics

Today’s Topics

• Create multiple actions from a single action.


• Define an action as reusable.
• Call a reusable action into a main test.
• Drive data using local and global data sheets.
The Integrate Phase
Single Action Test
A Test with Multiple Actions
Split an Action
Creating a New Action
Modifying an Action Name
One Action Used Many Times
Setting Actions as Reusables
Using an Existing, Copied, or a New Action
The Test Flow List
Action Data Structure
Deleting an Action
Using Global and Local Data Sheets in a Test
Using Parameterized Data
Using Global Data Table Sheets
Using Local Data Table Sheets
Data Table Iterations
External Action Properties
Handling Missing Action
Review Questions

Now answer these review questions.


1. Which action can you can use only within the test in which it was
created?
a) Reusable action
b) Regular (non-reusable) action
c) External action
2. Where do you set action iterations for a specified action?
a) Action Run Settings
b) Action Properties
c) Action Call Properties
Review Questions

3. Which of the following is created, by default, with a new action?


a) Global data sheet
b) Local object repository
c) Local data sheet
d) Folder
Exercise: Using Multiple and Reusable Actions

» Part 1: Create a reusable log in test


» Part 2: Change the default name of an action
» Part 3: Create a reusable NewOrder test
» Part 4: Create a main calling test
QTP Training – Day 6
Topics

Today’s Topics
» List the types of steps that can be added to a test without using the Record feature.
» Use conditional statements in a test.
» Use the Reporter feature to report events as a step in the test.
» Use Step Generator.
» Create a parameterized checkpoint.
» Compare captured parameter values with expected values.
» Use debug tools to investigate and cause failures.
» Verify that the reported error message reflects the state of the test.
» User Defined Functions
» Smart Identification Mechanism
Adding Steps Using Keyword View

The programming statements that are used to enhance a


test can contain:
» Recordable test object methods and operations that a user can perform on an
application but does not want to record.

» Non-recordable test object methods and operations that you cannot perform on an
application.

» Run-time methods of the object being tested.

» Functions associated with the Utility object and custom-designed functions.

» VBScript programming commands.


Inserting Steps Without Recording
Using Conditional Statements
Selecting Statement Type
Objects from Repository
Adding a Conditional Statement
Adding the Else Statement
Using Reporting
Reporting an Event
Using Step Generator
Operating on a Test Object
Using a Function
Using a Utility Object
Using the Report Object

12_Using_Database_Checkpoints.zip
Using a Custom Checkpoint

You use a custom checkpoint to:


» Capture and verify dynamic values in the test by using output
parameters.
» Validate the test outcome as acceptable or unacceptable by using a
conditional statement.
» Apply ReportEvent to report if the test outcome is acceptable.
Generating a Dynamic Value as Output
Setting a Parameterized Checkpoint
Calculating the Outcome Value
Using Data Table Formula Capabilities
Run-Time Data Table Output
Adding the DataTable Object
Adding a Conditional Statement
The Debug Toolbar
Using a Breakpoint
User Defined Functions

• Working with User Defined Functions


• Working with Associated Library Files
>> Test ->Settings-> Resources
• Executing externally-defined functions
>> Executefilename <path>
Smart Identification
If Quick Test is unable to find any object that matches the recorded object description, or if it finds more than one object
that fits the description, then Quick Test ignores the recorded description, and uses the Smart Identification mechanism
to try to identify the object.

The Smart Identification mechanism uses two types of properties


• Base filter properties
• Optional filter properties

Prepare Object Candidate List

Filter the Objects that do not match the Option Filter List

>1 =0
`
Objects Ignore that Optional Filter Property

=1

End

Você também pode gostar