DbgServices.LaunchTestedApplication Method

Applies to TestComplete 15.42, last modified on September 08, 2022

Description

The DbgServices.LaunchTestedApplication method launches a application from the list of the current project's Tested Applications project item. Once the application is launched, the DbgServices object traces all relevant application events and posts them to the test log when they occur.

Declaration

DbgServices.LaunchTestedApplication(Index)

Index [in]    Required    Integer    
Result A Process object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Index

The zero-based index of the desired tested application listed in the TestedApps project item. To learn the number of applications in this list, use the TestedApps.Count property.

Result Value

The method returns the process object that corresponds to the created application instance, if the launch was successful.

If the launch was not successful, the method returns an empty object. Use Exists to check if the returned object is a valid process.

Remarks

The method launches the tested application according to the tested application’s run mode. If the Simple or Debug mode is active, the method launches the application and then assigns debugging permissions to the TestComplete process to allow it to trace the application’s events.

If RunAs mode is active, the method performs similar actions, but launches the application under the user account that is specified by the application properties.

If run mode is set to Profile, the method does not launch an application and posts an error message to the test log.

If the tested application’s Launch is False, the method does not run the tested application.

The method ignores the Count properties of the tested application. It always starts one new application instance.

Note: When launching an application, the operating system displays a dialog box asking for your permission to run it. Due to certain limitations, the closing of this dialog box cannot be automated. You should close it manually, or modify User Account Control settings so that Windows does not display the dialog. See Using TestComplete With Administrator Privileges.

Example

The code below launches the first application from the Tested Applications collection and then checks whether the application has started successfully.

JavaScript, JScript

function LaunchTestedApp()
{
  var AppIndex = 0;
  var Proc = DbgServices.LaunchTestedApplication(AppIndex);
  var Res = Proc.Exists;
  
  // Checks whether the application has started successfully
  if (Res)
    Log.Message("The application has been started successfully.")
  else
    Log.Message("The application hasn't been started.");

}

Python

def LaunchTestedApp():
  AppIndex = 0
  Proc = DbgServices.LaunchTestedApplication(AppIndex)
  Res = Proc.Exists
  # Checks whether the application has started successfully
  if Res:
    Log.Message("The application has been started successfully.")
  else:
    Log.Message("The application hasn't been started.")

VBScript

Sub LaunchTestedApp

  AppIndex = 0
  Set Proc = DbgServices.LaunchTestedApplication(AppIndex)
  Res = Proc.Exists
  
  ' Checks whether the application has started successfully
  If Res Then
    Log.Message("The application has been started successfully.")
  Else
    Log.Message("The application hasn't been started.")
  End If
    
End Sub

DelphiScript

function LaunchTestedApp;
var Proc, Res;
begin

  AppIndex := 0;
  Proc := DbgServices.LaunchTestedApplication(AppIndex);
  Res := Proc.Exists;
  
  // Checks whether the application has started successfully
  if Res then
    Log.Message('The application has been started successfully.')
  else
    Log.Message('The application hasn''t been started.');

end;

C++Script, C#Script

function LaunchTestedApp()
{
  var AppIndex = 0;
  var Proc = DbgServices["LaunchTestedApplication"](AppIndex);
  var Res = Proc["Exists"];
  
  // Checks whether the application has started successfully
  if (Res)
    Log["Message"]("The application has been started successfully.")
  else
    Log["Message"]("The application hasn't been started.");

}

See Also

LaunchApplication Method
LaunchAllTestedApplications Method
AttachToProcess Method
Run Method
RunAll Method
Items Property
Count Property
Run Modes and Parameters

Highlight search results