Monday, November 12, 2007

QTP Action Parameter

1. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens.

2. Go to 'Parameters' Tab. Click on '+' sign which is on the top right.

3. Enter the Name of the parameter as 'a' and its Type as Number. In the same way create another Number parameter 'b'.

4. Click Ok.

5. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens. In the general tab, click on 'Reusable Action' checkbox at the bottom to make the action reusable.

6. In the Expert View of Action1 type:

s1=parameter("a")
s2=parameter("b")
msgbox(s1+s2)

7. Go to Insert (menu)-> Call to New Action. 'Insert Call to New Action' window opens. Just click ok to insert a new action.

8. Make action2 reusable as we did for action1.

9. In the Expert View of action2 type:

RunAction "Action1", oneIteration, 2,2

10. In the keyword View right click on action2 and select 'Run from Step', it will show you the sum 4 in msgbox.