Introduction
The basic component of a QTP Test is an action. This
document starts with a brief introduction on QTP Test, Test flow and Actions
followed by stepwise guidelines for using test and action parameters in a QTP
Test.
2.
Test and Test Flow
One ‘Test’ can have multiple actions and the test flow
(sequence of actions) can be done by drag and drop of actions within the test
in ‘Keyword View’. The test flow can be viewed in ‘Keyword View’ by selecting
‘Test Flow’ in the dropdown in ‘Keyword View’

3.
Actions
Actions can be specific to a test or can be reusable
actions. An ‘Action’ can be made reusable by checking the checkbox ‘Reusable
Action’ in ‘Action Properties’ (Right Click in Expert View of an ‘Action’->
Action -> Action Properties OR Right click on any Action name in Keyword
View -> Action Properties)


3.1
Reusable Actions
Actions within the test which are reusable can be
called as:
RunAction “Action Name within the Test”, oneIteration
Actions outside the current test which are reusable can
be called as:
RunAction “Action Name [Test Name]”, oneIteration
3.2
Deleting Actions
Actions can be deleted from a ‘Test’ by right clicking
on the ‘Action’ name in ‘Keyword View’ selecting ‘Delete’ from the drop down
list.
Note:
If any reusable action’s name is changed, it will affect all the calls to that
action. So the already existing calls have to be deleted and replaced with new
calls to that action.
4.
Test and Action Parameters
4.1
Test Parameters
Test parameters can be set by selecting Parameters tab
in File->Settings

Input Test parameters are used to pass values to the
Test from any external source.
When a test runs, the
actual values used for parameters are generally those sent by the application
calling the test (either Quick Test or Quality Center) as described below:
Quick Test: Parameters
sent through ‘Input Parameters tab of the Run dialog box’

Quality Center: Test Run Properties dialog box (Test
Lab module)
Output Test parameters are used to pass values to any
external source from the test.
4.2 Action Parameters
Action parameters can be set through Parameters tab in
‘Action Properties’ dialog box (Right Click in Expert View of an ‘Action’->
Action -> Action Properties OR Right click on any Action name in Keyword
View -> Action Properties)

Input parameters of an action are used to pass values to
the action from elsewhere in the test. Input values for an action parameter can
be retrieved from the test (for a top-level action) or from the parameters of
the parent action that calls it (for a nested action), or from the output of a
previous action call (for a sibling action).
Output parameters for an action are used to return values
from the action which can be used later in the test. For example, you can
output a parameter value to a parent action so that a later nested action can
use the value.
4.3
Passing Input Test Parameters to Actions
Test Input parameters
can be accessed in actions only by parameterizing the value of a top-level
action input parameter. If nested actions or child actions has to access the
Test Input Parameters, then it has to be passed through the Parent actions.
Following steps have
to be followed in order to access Input Test Parameters in actions which are at
the top level (actions sequenced in Test Flow).
- Define the input test parameter (File >
Settings > Parameters tab) with the value that you want to use
later in the test.

- Define an input action parameter for the top level
action (Here for the action ‘Start’) (Edit > Action > Action
Properties > Parameters tab) with the same value type as the input
test parameter.

- Parameterize the input action parameter value (Edit
> Action > Action Call Properties > Parameter Values tab)
using the input test parameter value you specified above. Click on the
‘Parameterize’ icon in the ‘Value’ column and a new dialog box will open
as below through which the action parameter (Here ‘a’) can be made to get
the value of test parameter (Here ‘a’)


Once the above
parameterization is done, the test input parameters can be accessed inside the
action (Here ‘Start’) by using the following statement in Expert View,
Dim Var1 = Parameter
(“a”)
The same can be stored
in a user defined environment variable by using the following statement,
Environment
(“Environment Variable Name”) = Parameter (“a”)
4.4
Passing Input Test Parameters to nested actions
After passing the test
input parameters to the top level actions, the same can be passed to the nested
actions (child actions) by following the below steps.
- Define an input action parameter for the action that
has been called by another action (Here ‘Start’ calling ‘ReusableOne’) (Edit
> Action > Action Properties > Parameters tab) with the same
value type as the input test parameter in the calling action (Here
‘Start’).
- Parameterize the input action parameter value. Choose Edit > Action > Action Call Properties
> Parameter Values tab and select the input action parameter value
as specified in the calling action (Here ‘Start’).
By doing the above step
in ‘Keyword View’, the parameter arguments will be added as ‘Parameter Utility
Object’ in the ‘Run Action’ statement in ‘Expert View’.
The same can be
achieved through scripting by using the Parameter Utility object as the
parameter argument for ‘Run Action’ statement in ‘Expert View’
as given below.
RunAction
"ActionName", oneIteration, "Input Parameter 1",
"Input Parameter 2",..,"Input Parameter n", “Output Parameter 1”,“Output Parameter
2”,..,“Output Parameter n”
RunAction
"ReusableOne", oneIteration, Parameter("a")
Steps 4 and 5 can be
repeated as required when the input test parameters have to be passed to other
nested actions from the first level nested action. Say here, ‘Start’ is calling
‘ReusableOne’ action and sends the input test parameter ‘a’ to ‘Reusable One’
action. Similarly, ‘ReusableOne’ action can pass this parameter to the actions
which it is calling.
4.5
Passing Output Test Parameters from Actions
Test Output parameters
can be passed from the actions to the Test from specifying the storage location
for a top-level output parameter (Output Parameter at the top level action Here
‘Start’).
Following steps have
to be followed in order pass the values to Output Test Parameters from actions
which are at the top level (actions sequenced in Test Flow).
- Define the output test parameter (File >
Settings > Parameters tab) with the value that you want to use
later in the test.

- Define an output action parameter for the top level
action (Here for the action ‘Start’) (Edit > Action > Action
Properties > Parameters tab) with the same value type as the input
test parameter.

- Store the output action parameter value (Edit
> Action > Action Call Properties > Parameter Values tab) in
the Output Action Parameter.

- Click on the ‘Store in’ icon in the ‘Store In’
column and the Storage Options dialog box will open as below through which
the output action parameter value can be passed (Here ‘OutputParamOne’) to
output test parameter (Here ‘OutputParamOne’)

Once the above
parameterization is done, the action (Here ‘Start’) can pass values to test
output parameters by using the following statement in Expert View,
Dim output = “Success”
Parameter
(“OutputParamOne”) = output
4.6
Passing Output Test Parameters from nested actions
An action which is
nested (not a top level action) can pass values to output test parameters by
following the below steps.
- Define an output action parameter for the action
that has been called by another action (Here ‘Start’ calling
‘ReusableOne’) (Edit > Action > Action Properties > Parameters
tab) with the same value type as the output test parameter in the calling
action (Here ‘Start’).
- Store the output action parameter value. Choose
Edit > Action > Action Call Properties > Parameter Values tab
and click on ‘Store In’ icon and select the same output parameter from
‘Storage Options’ dialog box.
By doing the above
step in ‘Keyword View’, the parameter arguments will be added as ‘Parameter
Utility Object’ in the ‘Run Action’ statement in ‘Expert View’.
The same can be achieved
through scripting by using the Parameter Utility object as the parameter
argument for ‘Run Action’ statement in ‘Expert View’ as given below.
RunAction
"ActionName", oneIteration, "Input Parameter 1",
"Input Parameter 2",..,"Input Parameter n", “Output Parameter 1”,“Output Parameter
2”,..,“Output Parameter n”
RunAction
"ReusableOne", oneIteration, Parameter("a"),
Parameter(“OutputParamOne”)
Here ‘a’ is the input
test parameter passed to the child action from the parent action and
‘OutputParamOne’ is the output test parameter which is stored by the child
action to the parent action.
Steps 5 and 6 can be repeated as required when values
have to be passed from actions which are further nested from the first level
nested action. If the output action parameter of the nested actions has to be
passed to the test output parameters, then it has to be passed to the output
parameter of the parent action and the parent action has to pass it to the Test
output parameter.
4.7
Passing output Parameter of One action as Input Parameter to another action
Output parameter of one action can be passed as input
parameter to another action only if both the actions are at the same
hierarchical level.

In the above Test, ‘Start’, ‘FunctionalityOne’ and
‘FunctionalityTwo’ actions are at the same hierarchical level. Similarly,
‘One’, ‘Two’, ‘ReusableOne’ and ‘ReusableAction2 [Test4]’ are at the same
hierarchical level.
For example, lets consider that the output parameter of
action ‘One’ is passed as input parameter to action ‘Two’. Following are the
steps to be followed to achieve this.
- Define an output parameter for action ‘One’ (Here
‘One2Two’) through ‘Action Properties’ dialog box.

- Define an input parameter with the same name in
action ‘Two’ (Here ‘One2Two’) through ‘Action Properties’ dialog box.

- Parameterize the input parameter ‘One2Two’ of action
‘Two’ through ‘Action Call Properties’ by selecting the Parameter as
‘One2Two’ from ‘Output from previous action call(s)’ list.

Output value from
action ‘One’ can be stored in the output parameter ‘One2Two’ by using the
following statement,
Parameter(“One2Two”) =
“Value”
If the input parameter
‘One2Two’ has to be used inside the action ‘Two’ itself, then it can be
accessed as ‘Parameter (“One2Two”)’
Example: Dim Var1 = Parameter(“One2two”)
When action ‘Two’ has
been called from another action, then the input parameter ‘One2Two’ can be
provided using the Parameter Utility Object in the ‘Run Action’ statement as
given below:
RunAction
"Two", oneIteration, Parameter("One", "One2Two")
5.
Conclusion
This document has
discussed on passing parameters from a QTP Test to actions, from one action to
another as well as returning parameters from actions to the calling Test.
0 comments :
Post a Comment