InvokeApplication LoadAndRunAction QTP

Description

Invokes an executable application.

Note: In most situations, you should use a SystemUtil.Run statement to run applications or to open files in their default application. For more information on the SystemUtil.Run statement, see the Standard Windows section of the HP QuickTest Professional Object Model Reference.
The InvokeApplication statement is supported primarily for backward compatibility.

Syntax

InvokeApplication(Command [,StartIn])



Argument

Type

Description

Command

String

The path and command line options of the application to invoke.

StartIn

String

Optional. The working folder to which the Command path refers.

Return Value

Boolean. If the function fails to open the application, False is returned.

Example

The following example uses the InvokeApplication function to open Internet Explorer.

InvokeApplication "E:\Program Files\Plus!\Microsoft Internet\IEXPLORE.EXE"


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.

Important Information

The action is loaded only when the step runs (and not when the test opens). Therefore:

  • The action is never listed in:

    • The Resources pane in QuickTest.

    • The Test Flow pane in QuickTest.

    • The Missing Resources pane in QuickTest.

    • The Dependencies tab in the Quality Center 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).

  • During a run session, you can view the actions that are run using the LoadAndRunAction statement. As an action begins to run, the action name is displayed in the LoadAndRunAction Calls section of the Action toolbar in the Keyword View and in the Expert View. The called actions remain listed in the toolbar until the end of the run session, at which point they are cleared from the list.

  • At the end of a run session, all of the actions that were dynamically loaded are unloaded. In the Test Results window, you can view the steps that ran during the run session.

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, a Quality Center 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 information, see ExitAction Statement.

Example 1:

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

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.


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

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

TestPath="c:\QTPTest\"

While NumOfOrder > 0

NumOfOrder = NumOfOrder - 1

If CustomerType = "Gold" Then

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

Elseif CustomerType = "Silver" Then

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

Elseif CustomerType = "Normal" Then

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

Else 'Error value

Msgbox "WrongDataValue CustomerType "

End If

Wend

Post a Comment

أحدث أقدم