https://www.qatechies.com

HP QTP Utility Statements : LoadAndRunAction Statement

technical-concept-uft

HP QTP Utility Statements : LoadAndRunAction Statement


Welcome to this post! – ” HP QTP Utility Statements : LoadAndRunAction 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 : LoadAndRunAction 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.

 

LoadAndRunAction Statement

Abstract

The LoadAndRunAction statement is used to start the QTP or UFT test action. You can call any external action you want to load and run within your different test action.

The statement in itself falls under the category of utility statements and not utility objects.

**Remember there is a difference between utility statements and 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 get your windows application invoked in the test run?
  2. Can you associate the parameters to the LoadAndRunAction statement?
  3. What are the objects and parameters of LoadAndRunAction statement?
  4. is LoadAndRunAction is an object or statement?
  5. What is the difference between LoadAndRunAction and RunAction statements?

 

Discussion

The LoadAndRunAction statement loads the specified test action when this step or statement is executed, and then runs the action.

Suppose you have a main test which have many test actions. Plus you want to call some external actions which are part of some other test. These external actions call sequence is not clear to you but you completely understand that these steps can be called within the main test action. In this case, of course, you can opt for calling those external ones via this statement.

The next question comes is what about the OR and other related artifacts of external action?.

When ever the external action is called all is imported during run and nothing before that. So this reduces overwork and chaos floating around and streamlines the process.

You can pass parameters too, if the called external actions has defined already.

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).

 If you want to iterate the external action, then you can use

oneIteration or 0 (Default)—Runs the action only once, using the row in the action’s data sheet that corresponds to the global data sheet iteration counter.

If the action’s data sheet contains fewer rows than the global sheet, the last row of the action’s data sheet will be used for each subsequent iteration.

allIterations or 1—Runs iterations on all rows.

 

Points to note here:

  1. This LoadAndRunAction statement is not supported in the Command tab of the Debug Viewer pane.
  2. If the action called by the LoadAndRunAction statement includes an ExitAction statement, the LoadAndRunAction statement returns the value of the ExitAction’s RetVal argument. For more information, see ExitAction Statement.

 

Syntax

LoadAndRunAction(TestPath, ActionName, [Iteration], [Parameters])

  

Let’s see the parameters and their usage description for this statement:

Argument Type Description
TestPath Variant The path of the test containing the action. You can specify an absolute file system path, a Quality Center path, or a relative path.
ActionName Variant The name of the action.
Iteration Variant This is Optional.

oneIteration or 0 (Default)

allIterations or 1—Runs iterations on all rows.

Parameters Variant This is Optional.

The values and storage locations for the called action’s input and output parameters. Input parameters are listed before output parameters.

 

Return Value

Variant.

 

Example 1

The following example loads Action1 in QTPTest1 and runs one iteration of the action.

'The following example loads Action1 in Test1 and runs one iteration of the action.

CustType = DataTable.Value("Cust_Type","dtGlobalSheet")

NumOfOrder = DataTable.Value("Number_of_items","dtGlobalSheet")

While NumOfOrder > 0

            NumOfOrder = NumOfOrder - 1

        If CustType = "Gold" or CustType = "Silver" or CustType = "Bronze" Then

            LoadAndRunAction "c:\QTPTest\OrderActions", CustType&"Order"

        Else 'Error value

            WrongDataValue CustType

        End If

Wend

 

Example 2

The following example also loads Action1 in Test1 and runs one iteration of the action. This example uses an environment variable for the TestPath parameter.

'Example 2

CustType = DataTable.Value("Customer_Type","dtGlobalSheet") 

OrderCnt = DataTable.Value("Number_of_items","dtGlobalSheet") 

 TestPath="c:\QTPTest\" 

 While OrderCnt > 0 

	OrderCnt = OrderCnt - 1 

	If CustType = "Gold" Then 

		LoadAndRunAction Environment("default_path")&"OrderActions", "GoldOrder",oneiteration, OrderCnt 

	Elseif CustType = "Silver" Then 

		LoadAndRunAction TestPath&"OrderActions", "SilverOrder", oneiteration, OrderCnt 

	Elseif CustType = "Normal" Then 

		LoadAndRunAction TestPath&"OrderActions", "NormalOrder", oneiteration, OrderCnt 

	Else 'Error value 

		Msgbox "WrongDataValue CustType " 

	End If 

Wend

 

 

This brings us to the end of our discussion on “HP QTP Utility Statements : LoadAndRunAction 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 !!