TestedApps Object

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

TestComplete projects can include the TestedApps project item. This item holds a list of tested applications.

Use the TestedApps object to access the list of tested applications from tests.

The TestedApps object is a collection of TestedApp objects corresponding to tested applications.

The TestedApps object is available only if you have the TestedApps project item in your project.

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

About Tested Applications
Working With Tested Applications in Tests
TestedApp Object

Highlight search results