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