TestedApps.Delete Method

Applies to TestComplete 15.63, last modified on April 10, 2024

Description

The Delete method removes the application's item specified by its name or index from the current project's list of tested applications.

Declaration

TestedApps.Delete(Index)

Index [in]    Required    Variant    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Index

The name or zero-based index of the item to be removed from the list of applications. Use TestedApps.Find to find an application's index. Use the TestedApps.Count property to find the total number of applications in the list.

Result Value

True if the application was successfully deleted from the list of tested applications, and False otherwise.

Example

The following example deletes the tested application specified by its index.

JavaScript, JScript

function DeleteTestedApp()
{

  var TestAppIndex, TestAppName;
  // Specifies the index of the tested application
  TestAppIndex = 2;
  // Checks if the project contains an application with the specified index
  if (TestAppIndex > TestedApps.Count - 1)
    Log.Warning("The project does not contain an application with the specified index " + aqConvert.IntToStr(TestAppIndex))
  else
    {
    // Obtains the name of the application you want to delete
    TestAppName = TestedApps.Items(TestAppIndex).ItemName;
    // Deletes the specified application and checks if it has been deleted successfully
    if (TestedApps.Delete(TestAppIndex))
      Log.Message("The " + TestAppName + " application has been deleted successfully.")
    else
      Log.Error("Failed to delete the " + TestAppName + " application from the project.");
    }

}

Python

def DeleteTestedApp():
  # Specifies the index of the tested application
  TestAppIndex = 2
  # Checks if the project contains an application with the specified index
  if TestAppIndex > (TestedApps.Count - 1):
    Log.Warning("The project does not contain an application with the specified index " + aqConvert.IntToStr(TestAppIndex))
  else:
    # Obtains the name of the application you want to delete
    TestAppName = TestedApps.Items[TestAppIndex].ItemName
    # Deletes the specified application and checks if it has been deleted successfully
    if TestedApps.Delete(TestAppIndex):
      Log.Message("The " + TestAppName + " application has been deleted successfully.")
    else:
      Log.Error("Failed to delete the " + TestAppName + " application from the project.")

VBScript

Sub DeleteTestedApp

  Dim TestAppIndex, TestAppName
  ' Specifies the index of the tested application
  TestAppIndex = 2
  ' Checks if the project contains an application with the specified index
  If TestAppIndex > TestedApps.Count - 1 Then
    Log.Warning("The project does not contain an application with the specified index " & aqConvert.IntToStr(TestAppIndex))
  Else
    ' Obtains the name of the tested application you want to delete
    TestAppName = TestedApps.Items(TestAppIndex).ItemName
    ' Deletes the specified application and checks if it has been deleted successfully
    If TestedApps.Delete(TestAppIndex) Then
      Log.Message("The " & TestAppName & " application has been deleted successfully.")
    Else
      Log.Error("Failed to delete the " & TestAppName & " application from the project.")
    End If
  End If

End Sub

DelphiScript

procedure DeleteTestedApp();
var TestAppIndex, TestAppName;
begin

  // Specifies the index of the tested application
  TestAppIndex := 2;
  // Checks if the project contains an application with the specified index
  if TestAppIndex > TestedApps.Count - 1 then
    Log.Warning('The project does not contain an application with the specified index ' + aqConvert.IntToStr(TestAppIndex))
  else
    begin
    // Obtains the name of the application you want to delete
    TestAppName := TestedApps.Items(TestAppIndex).ItemName;
    // Deletes the specified application and checks if it has been deleted successfully
    if TestedApps.Delete(TestAppIndex) then
      Log.Message('The ' + TestAppName + ' application has been deleted successfully.')
    else
      Log.Error('Failed to delete the ' + TestAppName + ' application from the project.');
    end;

end;

C++Script, C#Script

function DeleteTestedApp()
{

  var TestAppIndex, TestAppName;
  // Specifies the index of the tested application
  TestAppIndex = 2;
  // Checks if the project contains an application with the specified index
  if (TestAppIndex > TestedApps["Count"] - 1)
    Log["Warning"]("The project does not contain an application with the specified index " + aqConvert["IntToStr"](TestAppIndex))
  else
    {
    // Obtains the name of the application you want to delete
    TestAppName = TestedApps["Items"](TestAppIndex)["ItemName"];
    // Deletes the specified application and checks if it has been deleted successfully
    if (TestedApps["Delete"](TestAppIndex))
      Log["Message"]("The " + TestAppName + " application has been deleted successfully.")
    else
      Log["Error"]("Failed to delete the " + TestAppName + " application from the project.");
    }

}

See Also

TestedApps.Add
TestedApps.Find
TestedApps.Items
TestedApps.Count
TestedApp Object

Highlight search results