HP QTP Utility Statements : RunAction Statement
September 10, 2018
HP QTP Utility Statements : RunAction Statement
Welcome to this post! – ” HP QTP Utility Statements : RunAction Statement”.
If you are looking for HP UFT, QTP utility statements and their usages, then you are at right place. This post “HP QTP Utility Statements : RunAction Statement” consists of concept discussion and usage discussion. Go ahead and enjoy reading…
This discussion will help you prepare well if you are going for the interview and can help you if you need the function to be used in your project test suite.
RunAction Statement
Abstract
The RunAction statement is used to run the specified action in the test.
The statement in itself falls under the category of utility statements and not utility objects.
Before we dig down deep into the usage let’s quickly visit some general questions.
In the interview usually, you might be questioned in different ways like:
- How to call action contained within test?
- Can you use the RunAction and LoadAndRunAction statements one after the other?
- What are the objects and parameters of RunAction statement?
- Is RunAction is an object or statement?
Discussion
Suppose you have lot of actions in a test, and while writing code in function file for some module you require to mention the action name to be called. When you start writing in the function file you don’t get option to create or generate step in that case you can use your own custom function file containing those actions which you want to call at a particular time. Whenever you want to call just use the statement and mention the action name to be called.
You would like to go through below points :
The RunAction statement can run only actions that are already associated with your test as part of the test flow. Therefore, in order to enter a RunAction statement in the Expert View for an external action, you must first insert a call to the action (Insert > Call to Action) or copy the external action (Insert > Copy of Action) into your test.
Using this option (copy to action or call to action) associates the action with the test and also inserts a RunAction statement for you. After the external action is added to the test flow, you can add additional calls to that external action in the Expert View.
If you insert a RunAction statement in the Expert View for an external action that is not already associated with your test as a part of the test flow, the RunAction statement fails.
You can also pass parameters if you have specified.
For an input parameter, specify either a fixed value or the name of another defined parameter (Data Table parameter, environment parameter, or an action input parameter of the calling action) from which the argument should take its value.
For an output parameter, specify either a variable in which you want to store the value or the name of a defined parameter (Data Table parameter, environment parameter, or an action output parameter of the calling action).
Points to note here:
- For calling an external action from within a function library. Instead, use the LoadAndRunAction Statement.
- This statement is not supported in the Command tab of the Debug Viewer pane.
- Iteration is required when calling an external action, but optional when calling a local action (from within the test).
- If the action called by the RunAction statement includes an ExitAction statement, the RunAction statement returns the value of the ExitAction’s RetVal argument. For more information, see ExitAction Statement.
Syntax
RunAction ActionName, [Iteration , Parameters]
Let’s see the parameters and their usage description for this statement:
Argument | Type | Description |
ActionName | String | The name of the action. |
Iteration | Variant | Optional.
— oneIteration or 0 (Default) — allIterations or 1—Runs iterations on all rows. |
Parameters | Variant | Optional. |
Return Value
Variant.
Example 1
If you have UFT installed, then you must have sample flight reservation system installed too. You can use below example on that. This example calls the SearchFlight action, and runs all iterations of the action.
'RunAction Example RunAction "SearchFlight", allIterations
Example 2
The following example performs the same call as the previous example, but runs only one iteration of the action and saves the returned value to the actionVal variable.
'example 2 actionVal =RunAction ("SearchFlight", oneIteration)
Example 3
The following example runs one iteration of the action, supplies a string value of inputSampleValue for the input parameter, and stores the resulting value of the output parameter in a variable called OutputVariable.
'example 3 RunAction "Action2", oneIteration, "inputSampleValue", OutputVariable
This brings us to the end of our discussion on “HP QTP Utility Statements : RunAction Statement”.
I really hope you have enjoyed reading this short post. If you have any doubt on this please feel free to add your comment below.
And if you like to read more on UFT or QTP Technical Interview Questions please follow below links:
UFT Technical Interview Questions – Set 1
UFT Technical Interview Questions – Set 2
How to Download Resource From QC\ALM?
How to Upload Resource To QC\ALM?
Or if you prefer General Interview Questions please follow below links:
UFT General Interview Questions – Part 1
UFT General Interview Questions – Part 2
If you would like to keep track of further articles on UFT (QTP). I recommend you to SUBSCRIBE by Email and have new UFT articles sent directly to your inbox.