Parameterization is the process of replacing the constant/static values to a reusable parameter.
Parameterization using Action parameter in QTP (without using Data Table)
- Open QTP with a new blank test, in a new qtp test, select “Keyword view” Tab
- In the Keyword View right click on Action1 and select “Action Properties”, after clicking “Action properties” window opens.
- Go to “Parameters” tab, Click on “+” sign which is on the top right to add the parameters to the current action.
- Enter the name of the parameter as “value1” and select type as Number, In the same way create another parameter with type as number called “value2”
- Click ok button in Action Parameters tab
- In the keyword view right click on Action1 and select “Action Properties”, after clicking that “Action Properties” window opens, In the general tab, click on “Reusable Action’ checkbox at the bottom to make the action reusable.
- In the Expert View of Action1 types , Type the following code
- Go to Insert (menu) ->Click on Call to new Action link, after clicking the link “Insert call to New Action” window opens; click ok button to insert a new action.
- Make action2 reusable as did for action1
- In the Expert view of action2 type the following
RunAction “Action1”,oneIteration, 4,4 ‘4,4 are input values, can be changed at run time’
- In the keyword view right click on Action2 and select “Run from Step”, It will show the sum of the parameters in msgbox (in the above case result is 8)
How to change Parameter Name after Parameterization
Select the Appropriate action which the parameter to be renamed, Then Go to Keyword view, select the existing parameter, under value column Rename the value and open value configuration options then select parameter radio button and select the parameter and click ok button, Script’s will automatically replace the existing parameters to the modified one.
The value of the input can be changed before running the tests, and also can add multiple parameters.