LoadAndRunAction Statement
Description
Loads the specified action when this step runs, and then runs the action.
Use this statement when a static action call is not practical, or when you are not sure which action is going to be called. For example, you may use conditional statements that call external actions, and you do not want to load actions each time you open the test, since these actions may not be necessary during the run session.
Note: This statement is not supported in the Console Pane of the Debug panes.
Syntax
LoadAndRunAction(TestPath, ActionName, [Iteration], [Parameters])
Argument | Type | Description |
---|---|---|
TestPath | Variant | The path of the test containing the action. You can specify an absolute file system path, an ALM path, or a relative path. |
ActionName | Variant | The name of the action. |
Iteration | Variant | Optional. -- 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. -- iteration row range (for example, "1-7")—Indicates the rows for which action iterations will be performed |
Parameters | Variant | Optional. The values and storage locations for the called action's input and output parameters. Input parameters are listed before output parameters. 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). |
Return Value
Variant.
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 details, see ExitAction Statement.
IMPORTANT
The action is loaded only when the step runs (and not when the test opens). Therefore:
The action is not listed in the following (except during the run session):
The Solution Explorer pane in UFT One.
The Canvas in UFT One.
The Errors pane in UFT One.
The Dependencies tab in the ALM Test Resources module.
This can affect test maintenance because the action can potentially be modified or deleted with its parent test without anyone realizing that it is called by this test. Conversely, when performing maintenance on this test, this action can be overlooked because it is not clearly visible as a resource.
Run performance can be affected because the action is loaded and run during the run session (and not when the test is opened).
At the end of a run session, all of the actions that were dynamically loaded are unloaded. In the Run Results window, you can view the steps that ran during the run session.
Calling an external action from a function library using the RunAction statement results in a run-time error.
Workaround: Call the action using the LoadAndRunAction statement.
The following example loads Action1
in Test1
and runs one iteration of the action.
CustomerType = DataTable.Value("Customer_Type","dtGlobalSheet")
NumOfOrder = DataTable.Value("Number_of_items","dtGlobalSheet")
While NumOfOrder > 0
NumOfOrder = NumOfOrder - 1
If CustomerType = "Gold" or CustomerType = "Silver" or CustomerType = "Bronze" Then
LoadAndRunAction "c:\QTPTest\OrderActions", CustomerType&"Order"
Else 'Error value
WrongDataValue CustomerType
End If
Wend
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.
See also:
- CallServiceTest Statement
- CreateObject64 Statement
- DescribeResult Statement
- ExecuteFile Statement
- ExitAction Statement
- ExitActionIteration Statement
- ExitComponent Statement
- ExitComponentIteration Statement
- ExitTest Statement
- ExitTestIteration Statement
- GetLastError Statement
- InvokeApplication Statement
- IsPartialRun Statement
- LoadAndRunAction Statement
- LoadFunctionLibrary Statement
- ManualStep Statement
- Print Statement
- RegisterUserFunc Statement
- RunAPITest Statement
- SetLastError Statement
- UnregisterUserFunc Statement
- Wait Statement