QTP Action input output parameters Example 5
To Run this test, always go to Action4 and then, Automation (Menu) ->Run Current Action
What these Actions will do:
Action4 will call Action1 with two input values 2, 2.
Action1 sums those values (2+2=4) and assigns the sum to out_a1_1 (Action1’s output parameter).
Then Action1 passes the sum (i.e. 4) along with another number (3) to Action2 by calling Action2 in its last line.
Action2 multiplies those two values (4, 3) it got from Action1 and passes on the result of multiplication (12) and another number (5) to Action3, where these passed on values are added and the result is shown in a message box.
1. Open a new test. Obviously Action1 will be there by default.
2. Go to Insert-> Call to New Action, when ‘Insert Call to New Action’ window opens, just click on Ok. This adds Action2.
3. Similarly add Action3 and Action4.
4. In the Keyword View right click on Action1 and choose Action properties. Action Properties window opens and go to Parameters tab.
5. In the Parameters tab, click on the +, which is on the right hand side of input parameters. Add 1st input variable as in_a1_1 (in means input, a1 is for action1 and 1 is 1st variable) and keep its Type as Number, let all other things be default.Similarly add 2nd input variable in_a1_2 and one output variable out_a1_1 also a Number Type.
6. Similarly add input and output parameters for Action2 (input variables in_a2_1 & in_a2_2, output variable out_a2_1) and Action3
(input variables in_a3_1 & in_a3_2, output variable out_a3_1).
In the Expert view of Action1 type:
RunAction "Action2", oneIteration, parameter("out_a1_1"), 3
In the Expert view of Action2 type:
RunAction "Action3", oneIteration, parameter("out_a2_1"),5
parameter("out_a3_1")= parameter("in_a3_1") + parameter("in_a3_2")
In the Expert view of Action4 type:
RunAction "Action1", oneIteration, 2,2