Monday, March 10, 2008

QTP Action input output parameters Example 2

Action output value (value returned by a called action) can be stored in data table column.

Open a new test. By default, it will have Action1.

Go to Insert (Menu) -> Call to New Action, to add a new action at the end of the test.

Now we have Action1 and Action2 in this test.

In the Keyword View, right click on Action1 and choose Action Properties.

Go to Parameters tab and create input variable in_a1_1 with Type as Number. Rest everything be default.
(To create an input variable, you have to click on ‘+’ sign which is on the right hand side of Input parameters section).

Create another input variable in_a1_2, same as above.

In the Parameters tab, also create one output variable out_a1_1 with Type as Number
(To create an output variable, you have to click on ‘+’ sign which is on the right hand side of Output parameters section).

In the Expert view of Action1 type:


In the Expert view of Action2 type:

(When you copy this below code in Expert view of Action2, it may give you a warning that it will make Action1 reusable, just click on Ok)

RunAction"Action1", oneIteration, 2, 2, DataTable("Action1_out",dtGlobalSheet)

In the Global Data Sheet, where you have column names as A, B and so on, double click on A,

It will open Change Parameter Name box,

Enter the parameter name as Action1_out and click Ok.

To Run this test make sure Action2 is selected / highlighted if you are in the Keyword View or Action2 is selected from the dropdown above if you are in the Expert View and then choose Automation(Menu) -> Run Current action.