Wednesday, 24 September 2014

Action Parameters in QTP

Step-1: Create a test with the structure: Action1 on the top-level, Action2 embedded in Action1.

1) Open a new test.
2) Go to Insert -> Call to New Action.
3) Select the "After the current step" radio button.
4) Click . The new action should be inserted into Action1.

Example:
Action1
Action2

Step-2:
Define an input test parameter:

1) Go to Test -> Settings.
2) Select the Parameters tab.
3) Click the add button (+) for the Input parameters.
4) Enter the following values:
5) Name: TestParam
6) Type: String
7) Value: Hello
8) Click and .

Step-3:
Define an input parameter for Action1:


1) Right-clicking on Action1 and select Action Properties.
2) Select the Parameters tab.
3) Click the add button (+) for the Input parameters.
4) Enter the following values:
5) Name: Action1Param
6) Type: String
7) Click .

Step-4:
Parameterize the input action parameter in Action1: So that it pulls the value from the parameter defined in the test settings.

1) Right-click on Action1 and select Action Call Properties.
2) Select the Parameter Values tab.
3) Click on the cell under the Value column for Action1Param. You will see a button on the right of the cell, click it.
4) Select the "Parameter" radio button. "Test Parameter" should be selected by default.
5) In the Name drop-down list, select "TestParam", which matches the input parameter created in the test settings.

Step-5:
Repeat steps 3 and 4 for Action2:
1) Except name the input parameter Action2Param, and when parameterizing the input value, select Action1Param from the Name drop-down list.

Step-6:
In Action2 insert the following line using Expert View:
msgbox Parameter("Action2Param") The above steps can be repeated if you wish to pass more Parameters.



Example- Action1------------
result1=parameter("Actionparam1")
result2=parameter("Actionparam2")

parameter("ActionOutParam") = result1+result2


Action2---------------------
Runaction "Action1", OneIteration ,2,7, variable1
msgbox variable1
 


Output-7

No comments:

Post a Comment