https://www.qatechies.com

HP QTP Utility Statements : RunAction Statement

technical-concept-uft

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:

  1. How to call action contained within test?
  2. Can you use the RunAction and LoadAndRunAction statements one after the other?
  3. What are the objects and parameters of RunAction statement?
  4. 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:

  1. For calling an external action from within a function library. Instead, use the LoadAndRunAction Statement.
  2. This statement is not supported in the Command tab of the Debug Viewer pane.
  3. Iteration is required when calling an external action, but optional when calling a local action (from within the test).
  4. 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.


Other Utility Statements:
UNREGISTERUSERFUNC REGISTERUSERFUNC
SETLASTERROR GETLASTERROR
INVOKEAPPLICATION EXITTEST
EXITACTION EXITACTIONITERATION
DESCRIBERESULT EXECUTEFILE
EXITCOMPONENT EXITCOMPONENTITERATION
LOADANDRUNACTION PRINT
WAIT EXITTESTITERATION
LOADFUNCTIONLIBRARY CALLSERVICETEST
OBSOLETE MANUALSTEP
RUNACTION  

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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

advanced-floating-content-close-btn
https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5034726663464946 (adsbygoogle = window.adsbygoogle || []).push({});
advanced-floating-content-close-btn 
*************************** Do you want to learn TOSCA? Do you want to excel in Career? Try my New Courses: 1. Tricentis Tosca and Working with Excel   2. Tricentis Tosca and UI Automation Great News!!   Price has been slashed down for limited period of time.So Hurry!!! Click The Shown Links and Enjoy Learning. ***************************
 
error: Content is protected !!