TestedApp Object

Applies to TestComplete 15.20, last modified on January 19, 2022

Description

A TestComplete project can include a list of tested applications and their attributes (command-line parameters, the number of instances to run and so on). These applications are listed in the TestedApps project item. The TestedApp object holds one item from the list. It has methods and properties that can set application attributes, launch or close the application and so on.

To work with the entire list of Windows-based tested applications, use the TestedApps object. To get a TestedApp object as an item of this list, use the TestedApps.Items property or use code like the following:

JavaScript, JScript

var TestedAppObj = TestedApps.TestedApp_Name;

Python

TestedAppObj = TestedApps.TestedApp_Name

VBScript

Set TestedAppObj = TestedApps.TestedApp_Name

DelphiScript

TestedAppObj := TestedApps.TestedApp_Name;

C++Script, C#Script

var TestedAppObj = TestedApps["TestedApp_Name"];

where TestedApp_Name is the unique name of the tested application in the list.

Remarks

Members

Example

The sample code below shows how to use the TestedApps and TestedApp objects to add an application to the list of tested applications, modify its launch parameters, run the application, and then close it.

JavaScript, JScript

function TestProc()
{
  // Obtains the 2nd app in
  // the list of tested applications
  var app = TestedApps.Items(1);
  // Changes the command line
  app.Params.SimpleParams.CommandLineParameters = "NotOpenApp";
  // Launches the application
  var p = app.Run();
  // Tests the application
  ...
  // Closes the application
  app.Close();
  Delay(2000); // Waits until the application closes
  if (p.Exists)
    // If the application still exists, terminates it
    app.Terminate();
}

Python

def TestProc():
  # Obtains the 2nd app in
  # the list of tested applications
  app = TestedApps.Items[1]
  # Changes the command line
  app.Params.SimpleParams.CommandLineParameters = "NotOpenApp"
  # Launches the application
  p = app.Run()
  # Tests the application
  #...
  # Closes the application
  app.Close()
  # Waits until the application closes
  Delay(2000)
  if p.Exists:
    # If the application still exists, terminates it
    app.Terminate()

VBScript

Sub TestProc
  ' Obtains the 2nd app in
  ' the list of tested applications
  Set app = TestedApps.Items(1)
  ' Changes the command line
  app.Params.SimpleParams.CommandLineParameters = "NotOpenApp"
  ' Launches the application
  Set p = app.Run
  ' Tests the application
  ...
  ' Closes the application
  app.Close
  Delay 2000 ' Waits until the application closes
  If p.Exists Then
    ' If the application still exists, terminates it
    app.Terminate
  End If
End Sub

DelphiScript

procedure TestProc;
var
  p, app : OleVariant;
begin
  // Obtains the 2nd app in
  // the list of tested applications
  app := TestedApps.Items[1];
  // Changes the command line
  app.Params.SimpleParams.CommandLineParameters := 'NotOpenApp';
  // Launches the application
  p := app.Run;
  // Tests the application
  w := p.Window('MainWindowClass', 'MainWindowCaption');
  ...
  // Closes the application
  app.Close;
  Delay(2000); // Waits until the application closes
  if p.Exists then
    // If the application still exists, terminates it
    app.Terminate;
end;

C++Script, C#Script

function TestProc()
{
  // Obtains the 2nd app in
  // the list of tested applications
  var app = TestedApps["Items"](1);
  // Changes the command line
  app["Params"]["SimpleParams"]["CommandLineParameters"] = "NotOpenApp";
  // Launches the application
  var p = app["Run"]();
  // Tests the application
  ...
  // Closes the application
  app["Close"]();
  Delay(2000); // Waits until the application closes
  if (p["Exists"])
    // If the application still exists, terminates it
    app["Terminate"]();
}

See Also

TestedApps Object
AndroidTestedApp Object
BrowserTestedApp Object
ClickOnceTestedApp Object
About Tested Applications
TestedAppWebParams Object
Working With Tested Applications in Tests
Passing Command-Line Arguments to Tested Applications
Testing Applications Running Under Another User Account

Highlight search results