Tutorial-7 How to Add Steps in Tests using Step Generator feature of QTP
How to Add Steps in Tests using Step Generator feature of QTP
The most common way of creation of tests in QTP is by doing a live recording of the operations normally performed on the application under test.
Flexibility & power of the tests can be enhanced many times by adding various logical steps into the recorded framework. There are various methods of inserting logical / programming statements in the tests. Most common way is by the use of the Keyword View and with the help of Step Generator utility.
Step Generator utility can be used from the Keyword View as well as from the Expert View
The dialog box of Step Generator enables us to add steps to our tests in a highly user-friendly way. For using this utility we don�t have to be an expert of scripting languages & there is no need to remember by heart any of the syntax etc.
How do we use Step Generator to Add steps in our tests:
Step Generator utility offers selection out of variety of context-sensitive options for feeding the data & for adding steps into our tests. Step Generator utility presents
a dialog box for defining the steps, which utilize the following:a) Test object methods and properties
b) Utility object methods and properties
c) Calls to VBScript functions, internal script functions & library functions.
For instance, we can add a step for checking the existence of that object, or the object which stores the returned value of a method as an output value or as part of a conditional statement. We can parameterize any of the values in our step.
The first thing before launching the Step Generator utility for adding a new step is the selection of the location for insertion of the step in the test.
After launching the Step Generator utility following actions are performed.
1) Selection of the category for the step operation like selection of Test Object, Utility object or Function.
2) Selection of the required object or the function library source like Built-in or local script functions.
3) Selection of the appropriate method or function
4) Defining the arguments and return values. Parameterizing of the same if felt necessary.
This results into insertion of the desired step with the appropriate syntax in the test, by the Step Generator.
We can go on adding more & more steps at the same location without any need to close the Step Generator.
How to launch the Step Generator:
The Step Generator can be launched in three ways like:
1) From the Keyword View or Expert View while recording or editing your test.
2) From a Function Library
3) From the Active Screen while editing.
Launching Step Generator from the Keyword View or Expert View:
Step 1: While recording or editing, click the step, which we want the new step to follow. (After finishing the activity of defining the new step, QTP will insert it after this step.)
Step 2: Choose Insert > Step Generator or right-click the step and choose Insert Step > Step Generator. Alternatively, press F7.
The Step Generator dialog box opens and displays the object from the selected step in the Object box.
Launching the Step Generator from a function library:
Step 1: In the function library, click the location in which you want to insert the new step.
Step 2: Choose Insert > Step Generator, or right-click and choose Step Generator.
Alternatively, press F7.
The Step Generator dialog box opens.
How to Define Steps in the Step Generator Dialog Box
The Step Generator dialog box enables us to add steps, which perform operations, using test object methods, Utility object methods, or function calls.
When the Step Generator dialog box opens, the object from the selected step is displayed in the Object box and the default method for the object is shown in the Operation box.