The Step Generator is a utility in UFT that could be utilized to add test steps in a Test without writing the code manually. UFT has added this utility on purpose so that you do not need to memorize syntax or to be proficient in high-level VBScript.If you are a new learner to UFT this utility could be very beneficial for you. You can use the Step Generator from the Keyword View and also from the Editor.
You can launch the Step Generator using any of the following ways
- Go to the Design>Step Generator menu option.
- Press F7
The Step Generator will be launched.
The Step Generator utility provides options to define steps for the following three categories.
Adding Steps Using Test Objects Category in Step Generator
It is used to generate test steps using the test objects present in the Object Repository. Step Generator also gives you the option to select the object from the application if the same is not available in the object repository.
If the required Test Object is not available in the Object drop-down, click on the pointing hand icon as shown above. “Select Test Object” window will be displayed with the Object tree to let you select the required object. If the required object is not available in the object repository click on the cube icon button with a pointing hand to select an object from the application itself. Select the required object from the object tree and click on the “OK” button.
Now you have to select the operation you want to perform on the selected object. Click on the Operation drop-down, it will display a list of all the methods that can be performed on the object.
I have selected an object “userName” that is a WebEdit box. In order to show you an example, I have selected Set operation to set the text on it. After selecting the operation, you will see all the associated parameters with the method listed under the Arguments section.
You can add a constant value to the argument by clicking on the value column and manually set the value. The generated code is displayed under the Generated Step section.
Click on the “OK” button. The generated step will be added to the current action of the Test.
Browser("Mercury Tours").Page("Mercury Tours").WebEdit("userName").Set "TestUser1"
You can also parametrize the value rather than setting a constant value. Click on the <#> icon next to the value column or press Ctrl+F11. The Value Configuration Options window will be displayed. You can parametrize the constant value with either DataTable or Environment value.
To parameterize the value with DataTable, select the DataTable option, and enter the name of the parameter and click on the “OK” button.
The parameter name will be displayed in the value field.
If you want to wait for an object until it is displayed on the page, you can select WaitProperty as Operation and passed the values in the Value column. If you want to add more steps, check the “Insert another step” checkbox as shown above and click on the “OK” button. The generated step gets added to the script at the location where you had your cursor in the script before you opened the step generator.
If you select a method that has a return type, UFT automatically defines a variable where you want to store the output of the method as shown below. In the below example UFT will return either a True or False value depending on the existence of the object on the page.
Adding Steps Using Utility Objects Category
Let’s say, we have added a parameter UserName in the global sheet of the DataTable and want to retrieve its value at runtime in UFT.
Select the DataTable object and provide the name of the ParameterID and SheetID as shown below.
Now you can use the returned variable var_Value to parametrize the username field value.
var_Value = DataTable.Value("UserName", "DtGlobalSheet")
Browser("Mercury Tours").Page("Mercury Tours").WebEdit("userName").Set var_Value
Adding Steps Using Functions Category
- How To Add Checkpoints in UFT
- Create User-Defined Functions in UFT
- Read, Write and Update Excel File In UFT
- File System Object UFT | VBA
- All You Need to Know About Object Identification in UFT
- Descriptive Programming in UFT with Examples
- How to Use Virtual object in UFT to Identify Non-Standard Class Objects
- DataTable in UFT One | Example of Datatable Methods