Qtp With Descriptive Programming - Presentation Transcript
Automation Fundamental Concepts and Intro. about QTP 9.2
Automation Fundamental Concepts
What is Test Automation ?
Software Test Automation is the process of automating the steps of manual test cases using an automation tool Or utility to shorten the testing life cycle with respect to time…
When application undergoes regression, some of the steps might be missed out or skipped which can be avoided in Automation…
Automation helps to avoid human errors and also expedite the testing process…
To implement the Test Automation detailed planning and effort is required
Automation Fundamental Concepts
Automation saves time and effort which results in reduction of the Test life cycle…
Benefits of Automation
- Consistency of Test Execution
- Reducing cycle time of regression test cycles
- Data driven testing
- Repeatability
- Coverage
- Reliability
- Reusability of test wares
Automation Fundamental Concepts
Automation life cycle is a subset of the entire test life cycle…
Automation planning can be initiated in parallel to the test planning phase…
Factors to be considered in automation planning,
Stability of AUT (Application under test)
No of regression cycles to be performed
Compatibility of App platform with testing tools
Cost benefit analysis (ROI)
Availability of skilled resources
Regression Testing & Automation
When Automation is applicable?
Regression Testing Cycles are long and iterative.
If the application is planned to have multiple releases / builds
If it’s a long running application where in small enhancements / Bug Fixes keeps happening
Test Repeatability is required
Technologies Supported
Default Support 1. Standard Windows applications 2. Web objects / Applications 3. ActiveX controls 4. Visual Basic applications
Supported Add-ins QuickTest Professional Java Add-in 9.1 QuickTest Professional .NET Add-in 9.2 QuickTest Professional Oracle Add-in 8.2 QuickTest Professional PeopleSoft Add-in 8.2* QuickTest Professional Add-in 8.2 for SAP Solutions QuickTest Professional Siebel Add-in 8.0* QuickTest Professional Stingray Add-in 8.2 QuickTest Professional Terminal Emulator Add-in 8.0* QuickTest Professional VisualAge Smalltalk Add-in 8.2 QuickTest Professional Web Services Add-in 9.2
Supported Browsers
Microsoft Internet Explorer 6.0 Service Pack 1
Microsoft Internet Explorer 7.0
Netscape Browser 8.1.2
Mozilla Firefox 1.5
Mozilla Firefox 2.0
Add-in Manager
Default Add-ins
ActiveX
Visual basic
Web
Other Add-Ins
Siebel
Java
SAP
Oracle
.Net and many more
Add-in Manager Cont …
QTP’s Add-in Manager facilitates the users to select the technology / environment from variety of environments suitable for the AUT (Application Under Test)
Once an add-in is loaded, users can record that application in its supported environment and thus QTP recognizes the objects specific to the application under test (AUT) as loaded through Add-in Manager.
It is critical for the users to know the development technologies / environment of AUT, and load right Add-Ins while invoking Quick Test Pro.
Mercury QuickTest Professional
Introduction to QTP
QuickTest Professional, the Mercury advanced keyword-driven testing solution enables you to test standard Windows applications, Web objects, ActiveX controls, and Visual Basic applications. You can also acquire additional QuickTest add-ins for a number of special environments (such as Java, Oracle, SAP Solutions, .NET Windows and Web Forms, Siebel, PeopleSoft, Web services, and terminal emulator applications).
QuickTest Window
The QuickTest window contains the following key elements:
QuickTest title bar —Displays the name of the currently open test or component.
Menu bar —Displays menus of QuickTest commands.
File toolbar —Contains buttons to assist you in managing your test or component.
Testing toolbar —Contains buttons to assist you in the testing process.
Debug toolbar —Contains buttons to assist you in debugging your test or component (not displayed by default).
Action toolbar —Contains buttons and a list of actions, enabling you to view the details of an individual action or the entire test flow.
Test pane —Contains the Keyword View and Expert View tabs.
Active Screen —Provides a snapshot of your application as it appeared when you performed a certain step during the recording session.
Data Table —Assists you in parameterizing your test or component. For a test, the Data Table contains the Global tab and a tab for each action. For a component, the Data Table contains single tab.
Debug Viewer pane —Assists you in debugging your test or component. The Debug Viewer pane contains the Watch Expressions , Variables , and Command tabs (not displayed by default).
Status bar —Displays the status of the QuickTest application.
QTP - Main Window
QTP - Main Window
Test Pane:
Test Pane contains two labs to view the tests,
- Keyword View
- Expert View
Keyword View:
Quick Test Pro displays your test in the form of a collapsible, icon based tree…
Expert View:
Quick Test Pro displays the source code (VB Script) of the tests in this view.
QTP Window
1. Prepare to Record
Objectives
Review documented user steps of a business transaction.
Understand the application under test and its environment.
Prepare the test environment to utilize QuickTest Professional correctly.
Quick Test Professional - Record & Run Modes
Recording Modes
Normal
Analog
Low level
Run Modes
Normal
Fast
Update
Quick Test Professional -Tools Options General
Click on “Restore Layout” button to reset screens to the initial setting when QuickTest was first installed.
QuickTest Professional Options->General
A best practice when setting general options for QuickTest are to:
Deselect all check boxes except “Save data for integrating with performance testing …” and “Display Add-in Manager on startup”.
Click on “Restore Layout” button to reset screens to the initial setting when QuickTest was first installed.
Quick Test Professional - Tools Options Run
Quick Test Professional - Options Run
Best Practices for Options for Run Mode:
Run Mode as Normal:
This ensures that the execution arrow appears to help with trouble shooting the tests.
Synchronization becomes better for the AUT (Application Under Test)
Test Results:
Deselect the option “View Results when run session ends”
Mercury Tool Integration:
Select "Allow other Mercury products to run tests and components“
Screen Capture:
Save step screen capture to results "On error and warnings"
Automation Record and Run Settings
Record and Run Settings
Best Practices for Record & Run Settings
Set the options to configure QTP to "Record and run test on any open Windows- based application“
Set the option - This window will appear the first time you click on the Record button in the new test.
Manually recall this window by selecting Automation Record and Run settings
2. Create a Test
Objectives
Create a basic test from a manual test case.
Run a test and check for errors.
Store the test file.
Discuss the importance of initial and end conditions.
The User Interface
The QuickTest Professional user interface is broken up into a number of functional areas. You can choose to focus on one or more areas depending on the task you are performing.
Record a Test
Once the record button is pressed and test steps are performed , QuickTest listens and records the activities. This results in the recording and storing of each step of the business process. Each step consists of:
The object
The method (operation)
The method property (a value for the action performed on the object)
QuickTest should be running before the application under test is invoked. For some environments, this is mandatory.
Saving a Test
Saving the test in Quality Center
Only relevant when using QTP with QC
A bulls-eye symbol in the header with “Open Test from Quality Center” appears
A folder structure is listed under the parent directory “Subject”
You have the option to click the File System button on the upper right corner
Once you have logged into Quality Center:
Select your folder
Type in the test name
Save the file
Save a test in QuickTest Professional
If you are using QuickTest Professional alone the file system you will save to is under the QuickTest Professional’s test directory.
You have the option to save the test results along with the test.
Steps to Run a Test
From the QTP Toolbar, click on the Run Button.
A best practice is to use the temporary folder to hold the results while debugging your test.
Press the OK button to execute the Run command.
Viewing the Test Run
When you run a test, QuickTest performs each step as it was recorded.
You can watch in the AUT as QuickTest performs each step. A yellow arrow in the left margin of the KEYWORD VIEW points out the step currently running.
When QuickTest finishes running the test, you can open the Test Results window.
Steps to View the Results
Decide if results must be viewed.
If yes, select TEST->RESULTS from the QTP menu bar.
View the outcome of the test run.
Expand the results tree. From the Test Results menu bar, select
VIEW->EXPAND ALL
View Test Results
Failure “roll-up” to the parent at the top level of the tree.
Expand the Test Results tree to see the outcome of each step.
Navigate to the child step that caused the failure.
3. The Object Repository
Objectives
Define what a Quick Test Professional object is.
Describe the role of the Object repository
Identify a given object as part of a class.
Describe how objects are recognized by Quick Test Professional.
Use the Object Repository to find and add objects.
Change object logical names using the Keyword View.
Object Types
A Quick Test Professional object is a graphic user element in an application, such as a button or a drop-down list.
Objects are categorized into classes. Buttons, Graphic Images and Edit Boxes are a few examples of class types.
QuickTest Object Properties
In the example above, there are several objects called Buttons, two of which are:
Update Order
Delete Order.
The only way to distinguish one object from the other of the same class is by the difference in object characteristics. Specific characteristics of an object within QuickTest are called object properties.
QuickTest Recognizes Objects
QuickTest uses a method when it learns objects during the recording process.
QuickTest first looks at the object you are recording and stores it as a test object, determining its object class. For example, QuickTest might classify the test object as a standard Windows dialog box or a web button.
For each object class, QTP has a default set of properties that it always learns.
Usually, only a few properties are needed to uniquely identify an object.
Assigning a Logical Name
After learning the class and properties of an object, QTP assigns a name to the object. This is known as the object’s logical name.
QTP refers to the object in a recorded test by using its logical name.
Edit the logical name to make it more descriptive if you wish.
The logical name given to an object during recording may be sufficient, but changing a logical name can give clarity to the test and the documentation that is generated.
Stored Test Objects
Recorded object properties are stored in QTP’s Object Repository.
Each test has its own Object Repository, by default..
These “stored” objects are referred to as “ Test Objects”.
The purpose of a Test Object is to represent application objects in the test.
During a test run, QTP uses the Test Object to search for a match in the application during run time.
Steps to change A Logical Name
You can change an object’s logical name in the OBJECT REPOSITORY.
Right-click on the object at the KEYWORD VIEW level.
Choose OBJECT PROPERTIES.
Click on the REPOSITORY button.
The Object Properties Dialog
Once in the Object repository:
Right-click the object in the repository tree.
Choose RENAME.
Type a descriptive name for the object.
Click OK.
QuickTest Documentation
QuickTest updates the object name and documents it in the documentation field of the Keyword View.
IMPORTANT: if you start a brand new test, the test will record the original, default object names in the Object Repository.
4. Synchronization
Objectives
Define Synchronization.
How to synchronize the Test
Some Visual Cue Examples
Examine when and where synchronization is most helpful.
Add a synchronization step for a specified object.
What is Synchronization ?
Synchronization is a step added to a test that instructs QuickTest to wait for the state of a property on a particular object to change before proceeding to the next step in the test.
This is done while in RECORD mode.
The user/test waits for a visual indication that a step has completed so that the user/test can take the next step.
Synchronization point enables the anticipated time problems between the application and QTP.
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 Application
Quick Test defaults to allocating the same amount of time for every object.
Wait times often occur before an object becomes available for the next step. For example, in the Flights application, once the Insert Order button has been clicked, a process bar must complete to yield the Order No. associated with the reservation. The process bar may require additional time before the test can proceed. If insufficient time is allocated for these special circumstances, the test may fail.
The error message “Object not enabled” appears if QuickTest is running a test and proceeds to the next step before the previous step has fully processed.
Add a Synchronization Step While Recording
Synchronization points which instruct QuickTest to pause until an object property achieves a specific value. The easiest method is to add a synchronization point while recording.
A Synchronization step can be added manually after a test is recorded , as well.
Always add the synchronization point immediately after the step to be synchronized.
From the QTP menu bar, choose INSERT STEP SYNCHRONIZATION POINT
5. Object Repository
Object Repository is a place where QTP stores learned objects
Resources Object Repository Can add a New Object to the repository More properties for recognizing the object can be added to the list. The value of property can be edited here.
A checkpoint can be added after a test is created.
Use the Active Screen to select the field on which the checkpoint will be added.
Right-click on the appropriate field and choose “Insert Standard Checkpoint”.
Regular Expressions
Regular expressions enable Quick Test to Identify Objects and text strings with varying values.
Use a Regular Expression
A regular expression is a string that specifies a complex search phrase. By using
special characters you define the conditions of the search.
Note: There are 4 steps to ensure that a regular expression is inserted correctly.
From the Checkpoint Properties window, ensure Constant is enabled and click on the note paper icon.
Check Regular Expression checkbox.
If QTP sees there are characters that can be misconstrued as a regular expression, it will ask you to treat it as a literal character. Generally, you will answer No.
Add the regular expression. For example, Figure 6-6 will use [A-Z a-z]+.
7. Parameters
Objectives
Describe and use multiple parameter types.
Drive data in multiple iterations.
Analyze errors during iterations.
Parameterize a checkpoint.
Input Parameters For Data driven Tests
Input Parameters For Data Driven Tests
A data-driven test is one that runs a set of user actions with multiple input values. Data driving allows one script to test application functionality with many sets of data.
Automated data driven testing frees you to perform more tests, thus increasing test coverage. Speed, repeatability, free resources to do other kinds of quality control.
Input Parameter
Input Parameters allow you to replace a static, recorded value in a step with a dynamic placeholder (parameter), which represents an expandable range of values.
Input parameter names and their values are located in QuickTest’s Data Table.
Input parameter values are input into the application from some outside data source.
Steps to Create An Input Parameter
To create an input data table parameter:
Select the step in the Keyword View that contains the recorded input value.
From the Value column, click on the current value.
Click on the parameterize button.
The Constant value appears in the Value Configuration Options dialog box.
Set the Parameter Value
In the VALUE CONFIGURATION OPTIONS dialog, select the Parameter radio button and ensure that Data Table is selected from the drop-down list.
From the Name drop down list, enter a unique column name to create a new column in your data table or choose an existing column name from the data table.
Use the default Global data sheet to store values.
Enter the values that QTP will input after the test executes.
Supply Data to the Parameter
The design-time table is the central location for storing input parameter values.
The number of rows in the data table will cause the same number of test execution iterations to be run.
As a default, the design-time data table is displayed at the bottom of the QuickTest screen.
If you want to show or hide the data sheet, click on the icon in the toolbar.
Verify The Test Run
View the Test Results window to verify that each of the rows from the Design Time Data Table was used during the test run.
Expand the tree for each iteration (Row#) to view specific information about the execution of the specific row.
Parameterize a Checkpoint
You can use parameterized expected values to make your checkpoints dynamic. They Can be set on:
An object property in the Object Repository.
A checkpoint on a parameterized field.
A Test with Multiple Actions
Actions can be divided into logical sections, like the main sections of a transaction, or by specific business processes.
When you create a new test, it contains one action. By dividing your tests into multiple actions, you can design more modular and efficient tests.
Types of Actions
There are two kinds of actions:
Regular (Non-reusable)
Reusable
Tests that contain reusable actions can be used:
Locally
Externally
Insert Call to a New Action
You can add a new action during or after recording.
Select Insert ? New Action from the QuickTest main menu. The Insert New Action window appears.
Or use the “lego” icon on the toolbar to insert new action.
Using Parameterized Data
Test data can be passed from one test to another test using the value of an input parameter.
This creates a data flow between business processes.
The value passed from one business process to another will come from the Data Table.
Be aware of any data dependencies that occur within the business process.
Copied, Existing or New Action
After reusable actions are created, they can be called into a “Main Calling” test in three ways:
Call to New Action
Call to Copy of Action
Call to Existing Action
Set Actions as Reusable
Create a reusable action from the Action properties dialog.
Check the checkbox and click OK. A message will appear stating a description of a reusable
action.
Call An Action
You can do number of things with a reusable action, such as:
Call it multiple times within a test.
Call it from other tests.
View the components of the action tree (you cannot modify them except in the original script)
Insert a call to an external action (the action is inserted in read-only format)
as local editable copy
use the (read only) data from the original
action
Insert copies of non-reusable actions into your test, but you cannot insert calls to non-reusable actions.
One Action used Many Times
Rather than recording the login process three times in three separate tests, and enhancing this part of the script (with checkpoints and parameterization) separately for each test, you can create an action that logs into the application in one test.
Best Practice
Inserting calls to existing actions makes it easier to maintain our tests; when an object or procedure in your application changes. It only needs to be updated one time, in the original action.
Set Actions as Reusable
Create a reusable action from the Action properties dialog.
Check the checkbox and click OK. A message will appear stating a description of a reusable action.
On Action – Two Names
Use the Action Properties – General tab to modify the default label.
This makes the test easier for others to understand when viewing the test from the Keyword View tree.
Right-Click on Action and enter a logical name for the business process.
External Action Properties
An external action is a reusable action created in another test. The external action is inserted into the calling test in a read-only format.
Data from the external action’s data sheet can be imported as a local, editable copy or kept as read only. If read-only, the data can only be modified from the original test.
After a reusable action is called, you will see the parameters contained in each test appear in the Global or Local sheet depending on where you stored them in the original test.
Action Run Settings
Since there are two (or more) tests running, one right after another, you may need to specify the iteration for each separately.
To affect the run settings for a particular action, set them in the Action Call Properties dialog box.
Right-Click on the Action label in the Keyword View, and choose Action Call Properties from the list provided.
Defining an Action
The Action Properties dialog box enables you to define options for the stored action.
You can modify an action name, add or modify an action description, and set an action as reusable.
Passing Values to a Called Action
You can also define input and output parameters to be used by the action.
These settings apply each time the action is called.
Using an Action Parameter
Once parameters have been set in Action Properties, you can tell QuickTest that the parameter type being used is an Action Parameter.
The Test Flow List
The Test Flow List:
- Changes with the addition of a reusable action.
- Enables viewing of the action tree for a selected reusable or external action.
The test flow appears when a test is recognized as having called actions in your test.
An action tree displays all the details of the selected reusable or external action.
Action Data Structure
In the Action data structure, each Action will have its own:
Folder with an object repository
Local data table sheet
Run settings
Multiple Reusable Actions
When using multiple, reusable actions, keep the following in mind:
Actions can be called or copied from another test.
Run settings have to be set per action
As a default, all actions in a test use the same shared Object Repository.
Parameters and data from the called test are reflected in the calling test
An action can be deleted or an action call can be deleted.
Position your action calls separately or nest them with other actions.
Delete an Action
Because reusable actions can be used throughout your test or test set, when you delete an
action, you must decide to delete a specific occurrence of the action and/or all of its calls .
A different message appear when you are about to delete a non-reusable action.
8. Data Table Sheets - Global
The Global Data Sheet:
Enables you to create a new column or select an existing column in the Global sheet of the Data Table.
Inserts or outputs a value from or to current row of the global data sheet during each global iteration at run-time.
Provides a source of values that can be seen and used by any action.
Data Table Sheets - Local
When a Local Data Sheet is used:
The parameters and data will appear with different tabs in the main calling test’s Data Table.
It allows you to iterate reusable actions independently of any other called actions.
You will need to link parameters in the “main calling test”
9. Recovery Scenarios
To instruct Quick test to recover from unexpected events and errors that occur in the testing environment during the run session.
A Recovery scenario consists of
a) Trigger Event
b) Recovery Operation
c) Post Recovery Run Option
Recovery Scenario Wizard
We can create the recovery scenario using recovery scenario wizard.
Recovery scenario wizard consists of
a) Define the trigger event that interrupts the run session
b) Specifying the recovery operations required to continue
c) Choosing a post recovery test run operation
d) Specifying a name and description for the recovery scenario
e) Specifying whether to associate the recovery scenario to the current test and / or to all new tests.
Recovery Scenario Wizard
Creating Tests without Object Repository
We can use programmatic descriptions to perform an operation on an object that is not stored in the Object Repository.
Types of Programmatic descriptions
a) We can list the set of properties and values that describe the object directly in a test statement.
QTP: Object Repository, Descriptive Programming and Beyond
Interact with Test Objects not stored in the Object Repository
You can also instruct QT to perform methods on objects without referring to the object repository without referring to the object’s logical name. To do this you provide QT with a list of properties and values that QT can use to identify the object or objects on which you want to perform a method
10. Enhance TestCases With Descriptive Programming
You can describe an object directly in a test statement by specifying property : = value pairs describing the object instead of specifying an object’s logical name.
Do...Loop: Loops while or until a condition is true.
While...Wend: Loops while a condition is true.
For...Next: Uses a counter to run statements a specified number of times.
For each...Next: Repeats a group of statements for each item in a collection or each element of an array.
VB Script basics – Functions
Key areas in QTP
About the script structure
Actions (Simple, Nested, External, Re-usable)
Parameterization (Different Types)
Checkpoints (Programmatic Methodology)
Descriptive programming
Adv. Synchronization points
Exception Handling
About the script structure
Actions (Simple, Nested, External, Re-usable)
Standalone Actions
Nested Actions
Integration of Actions (Call from One Action to other)
Driver Action (Main Action)
Re-usable Actions
External Call for Actions
Parameterization
Classifications of Parameterization
Test and Action Parameters
Data Table (Global & Action Specific)
Environment variables
Random Number
Types of Checkpoints Standard Checkpoint Checks values of an object’s properties Check that a radio button is selected. Image Checkpoint Checks the property values of an image Check that the image source file is correct. Table Checkpoint Checks information in a table Check that the value in a table cell is correct. Page checkpoint Checks the characteristics of a Web page Check how long a Web page takes to load or if a Web page contains broken links. Text / Text Area Checkpoint Checks that a text string is displayed in the appropriate place in a Web page or application window Check whether the expected text string is displayed in the expected location on a Web page or dialog box 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.
Cont…. Database Checkpoint Checks the contents of databases accessed by an application or Web site Check that the value in a database query is correct. Accessibility Checkpoint Identifies areas of a Web site to check for Section 508 compliancy Check if the images on a Web page include ALT properties, required by the W3C Web Content Accessibility Guidelines. XML Checkpoint Checks the data content of XML documents Note: XML file checkpoints are used to check a specified XML file; XML application checkpoints are used to check an XML document within a Web page.
Descriptive Programming Samples
Descriptive programming
Entering Programmatic Descriptions Directly into Statements
0 comments
Post a comment