TestedApps.Find Method

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

Description

The Find method lets you obtain the index that an application with the given name has in the list of the current project’s applications to be tested. To find the total number of applications in the list, use the TestedApps.Count property.

Declaration

TestedApps.Find(FullName)

FullName [in]    Required    String    
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

FullName

The full path to the desired application’s executable or batch file, or the unique name of the tested application as it would appear in the list of applications to be tested.

Result Value

The integer value that represents the zero-based index of the found application in the current project's list of tested applications. -1 if the application is not found in the list.

Example

The following code obtains the index of the tested application specified by its name:

JavaScript, JScript

function FindTestedAppIndex()
{

  var AppName, AppIndex;
  // Specifies the unique name of the tested application
  AppName = "SampleApp";
  // Obtains the index of the tested application
  AppIndex = TestedApps.Find(AppName);

  if (AppIndex < 0)
    Log.Warning("The " + AppName + " application was not found in the project.")
  else
    Log.Message("The index of the " + AppName + " application is " + aqConvert.IntToStr(AppIndex) + " in the list of tested applications.");


}

Python

def FindTestedAppIndex():
  # Specifies the unique name of the tested application
  AppName = "SampleApp"
  # Obtains the index of the tested application
  AppIndex = TestedApps.Find(AppName)
  if (AppIndex < 0):
    Log.Warning("The " + AppName + " application was not found in the project.")
  else:
    Log.Message("The index of the " + AppName + " application is " + aqConvert.IntToStr(AppIndex) + " in the list of tested applications.")

VBScript

Sub FindTestedAppIndex

  Dim AppName, AppIndex
  ' Specifies the unique name of the tested application
  AppName = "SampleApp"
  ' Obtains the index of the tested application
  AppIndex = TestedApps.Find(AppName)

  If AppIndex < 0 Then
    Log.Warning("The " & AppName & " application was not found in the project.")
  Else
    Log.Message("The index of the " & AppName & " application is " & aqConvert.IntToStr(AppIndex) & " in the list of tested applications.")
  End If

End Sub

DelphiScript

procedure FindTestedAppIndex();
var AppName, AppIndex;
begin

  // Specifies the unique name of the tested application
  AppName := 'SampleApp';
  // Obtains the index of the tested application
  AppIndex := TestedApps.Find(AppName);

  if AppIndex < 0 then
    Log.Warning('The ' + AppName + ' application was not found in the project.')
  else
    Log.Message('The index of the ' + AppName + ' application is ' + aqConvert.IntToStr(AppIndex) + ' in the list of tested applications.');


end;

C++Script, C#Script

function FindTestedAppIndex()
{

  var AppName, AppIndex;
  // Specifies the unique name of the tested application
  AppName = "SampleApp";
  // Obtains the index of the tested application
  AppIndex = TestedApps["Find"](AppName);

  if (AppIndex < 0)
    Log["Warning"]("The " + AppName + " application was not found in the project.")
  else
    Log["Message"]("The index of the " + AppName + " application is " + aqConvert["IntToStr"](AppIndex) + " in the list of tested applications.");


}

The following code obtains the index of the tested application specified by its full path:

JavaScript, JScript

function FindTestedAppIndex()
{

  var AppFullPath, AppIndex;
  // Specifies the full path to the tested application
  AppFullPath = "D:\\Work Folder\\SampleApp.exe";
  // Obtains the index of the tested application
  AppIndex = TestedApps.Find(AppFullPath);

  if (AppIndex < 0)
    Log.Warning("The " + AppFullPath + " application was not found in the project.")
  else
    Log.Message("The index of the " + AppFullPath + " application is " + aqConvert.IntToStr(AppIndex) + " in the list of tested applications.")

}

Python

def FindTestedAppIndex1():
  # Specifies the full path to the tested application
  AppFullPath = "D:\\Work Folder\\SampleApp.exe"
  # Obtains the index of the tested application
  AppIndex = TestedApps.Find(AppFullPath)
  if AppIndex < 0:
    Log.Warning("The " + AppFullPath + " application was not found in the project.")
  else:
    Log.Message("The index of the " + AppFullPath + " application is " + aqConvert.IntToStr(AppIndex) + " in the list of tested applications.")

VBScript

Sub FindTestedAppIndex

  Dim AppFullPath, AppIndex
  ' Specifies the full path to the tested application
  AppFullPath = "D:\Work Folder\SampleApp.exe"
  ' Obtains the index of the tested application
  AppIndex = TestedApps.Find(AppFullPath)

  If AppIndex < 0 Then
    Log.Warning("The " & AppFullPath & " application was not found in the project.")
  Else
    Log.Message("The index of the " & AppFullPath & " application is " & aqConvert.IntToStr(AppIndex) & " in the list of tested applications.")
  End If
End Sub

DelphiScript

procedure FindTestedAppIndex();
var AppFullPath, AppIndex;
begin

  // Specifies the full path to the tested application
  AppFullPath := 'D:\Work Folder\SampleApp.exe';
  // Obtains the index of the tested application
  AppIndex := TestedApps.Find(AppFullPath);

  if AppIndex < 0 then
    Log.Warning('The ' + AppFullPath + ' application was not found in the project.')
  else
    Log.Message('The index of the ' + AppFullPath + ' application is ' + aqConvert.IntToStr(AppIndex) + ' in the list of tested applications.')

end;

C++Script, C#Script

function FindTestedAppIndex()
{

  var AppFullPath, AppIndex;
  // Specifies the full path to the tested application
  AppFullPath = "D:\\Work Folder\\SampleApp.exe";
  // Obtains the index of the tested application
  AppIndex = TestedApps["Find"](AppFullPath);

  if (AppIndex < 0)
    Log["Warning"]("The " + AppFullPath + " application was not found in the project.")
  else
    Log["Message"]("The index of the " + AppFullPath + " application is " + aqConvert["IntToStr"](AppIndex) + " in the list of tested applications.")

}

See Also

TestedApps.Add
TestedApps.Delete
TestedApps.Items
TestedApps.Count
TestedApp Object

Highlight search results