We can pass parameters in a Action Using input and output parameters.

Let’s take one example:

There are two actions in Test Script.Action1 and Action2. Action1 is Reusable. In Action2 we call Action1.How to Pass value from Action2 to Action1 and use it in Action1

Way 1:

So Now If you need pass parameters between actions first we have to add then in the action properties

Step->ActionProperties->Parameters
For your problem we have to add a new input parameter "x" for Action1
then write the following code in Action2
RunAction "Action1", AllIterations,k where k is the value being passed to action1 and should be defined with some value in action2

then write the following code in Action1

msgbox parameter("x")

Way 2:

Scenario: suppose you call Action2 from Action1 and Action2 has one input and one output parameter defined.

RunAction "Action2", oneIteration, “MyValue”, MyVariable

Supplies a string value of MyValue for the input parameter and stores the resulting value of the output parameter in a variable called MyVariable.

Sequence of events:
1. Create two Actions:
New Test -> Go to Insert -> Call to New Action -> Select "After the current step". Press OK.
2. Define Input Test Parameter:
Go to Test -> Settings -> Parameters tab -> ADD Input Parameter -> Enter the values, Press Apply and OK
For Action 1:
3. Define an input parameter for Action1:

Right-clicking on Action1 and select Action Properties -> Parameters tab -> ADD Input Parameter -> Enter the values, Press Apply and OK

Again Right-click on Action1 and select Action Call Properties -> Parameters tab -> Click on the cell under the Value column for [Parameter 1 of Action 1].

You will see a button on the right of the cell, click it. Select "Parameter" and "Test Parameter".
In the Name drop-down list, select "TestParam", which matches the input parameter created in the test settings.

Repeat Sequence 3 (Step 3) for Action 2 also. The name of input parameter for Action 2 will be “Param2”. Select [Parameter 1 of Action 1] in the Name dropdown.

4. Go to the Expert View of Action 2 and write the following code:
msgbox Parameter("Param2")

The above steps can be repeated if you wish to pass more Parameters.

0 comments