TestedApps.CloseAll Method

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

Description

The TestedApps.CloseAll method closes all the tested applications by sending the WM_SYSCOMMAND message with the SC_CLOSE parameter to the main window of the applications.

This method only affects the applications started from a script (by TestedApp.Run, TestedApp.RunAs or TestedApps.RunAll) or from the corresponding context menu items of the Tested Applications project item. If the application was started manually (for example, via the Windows Explorer) it is not added to the list of tested applications and therefore is not closed by the TestedApps.CloseAll method.

Declaration

TestedApps.CloseAll()

Result Boolean

Applies To

The method is applied to the following object:

Result Value

True, if all running instances of the tested applications were closed successfully; otherwise False.

Remarks

The CloseAll method waits until each tested application is closed during the time period specified by the Auto-wait timeout setting. If a tested application is not closed after the timeout period elapses, a warning message is posted to the test log.

You can call TestedApps.TerminateAll when CloseAll fails to stop the tested applications.

To close any process in the system, use the Process.Close or Process.Terminate method.

Example

The following code snippet tries to close all the running tested applications. If some of the applications is not closed successfully, it uses the TestedApps.TerminateAll method to terminate it.

JavaScript, JScript

function Test()
{

  // Launches all tested applications
  TestedApps.RunAll();
  // Performs testing actions
  …
  // Closes the tested applications
  if (! TestedApps.CloseAll() )
    {
    // If TestComplete fails to close some application, it is terminated
    Log.Warning("Some tested applications have not been closed successfully and will be terminated.");
    TestedApps.TerminateAll();
    }

}

Python

def Test():
  # Launches all tested applications
  TestedApps.RunAll()
  # Performs testing actions
  # ...
  # Closes the tested applications
  if not TestedApps.CloseAll():
    # If TestComplete fails to close some application, it is terminated
    Log.Warning("Some tested applications have not been closed successfully and will be terminated.")
    TestedApps.TerminateAll()

VBScript

Sub Test

  ' Launches all tested applications
  TestedApps.RunAll
  ' Performs testing actions
  …
  ' Closes the tested applications
  If Not TestedApps.CloseAll Then
    ' If TestComplete fails to close some application, it is terminated
    Log.Warning "Some tested applications have not been closed successfully and will be terminated."
    TestedApps.TerminateAll
  End If
End Sub

DelphiScript

procedure Test();
begin

  // Launches all tested applications
  TestedApps.RunAll;
  // Performs testing actions
  …
  // Closes the tested applications
  if not TestedApps.CloseAll then
    begin
    // If TestComplete fails to close some application, it is terminated
    Log.Warning('Some tested applications have not been closed successfully and will be terminated.');
    TestedApps.TerminateAll;
    end;

end;

C++Script, C#Script

function Test()
{

  // Launches all tested applications
  TestedApps["RunAll"]();
  // Performs testing actions
  …
  // Closes the tested applications
  if (! TestedApps["CloseAll"]() )
    {
    // If TestComplete fails to close some application, it is terminated
    Log["Warning"]("Some tested applications have not been closed successfully and will be terminated.");
    TestedApps["TerminateAll"]();
    }

}

See Also

RunAll Method
TerminateAll Method
Close Method
Terminate Method
Close Action (Process and Browser Objects)
Terminate Method (Process and Browser Objects)

Highlight search results