TestedApps.Add Method

Applies to TestComplete 15.46, last modified on January 09, 2023

Description

The Add method adds an application to the list of tested applications of the current project and returns the application’s list index (starting from 0). Use the TestedApps.Count property to find out the total number of applications in the list.

Declaration

TestedApps.Add(FullName, Parameters, Count, Launch, WorkDir)

FullName [in]    Required    String    
Parameters [in]    Optional    String Default value: Empty string   
Count [in]    Optional    Integer Default value: 1   
Launch [in]    Optional    Boolean Default value: True   
WorkDir [in]    Optional    String Default value: Empty string   
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

FullName

The full path to the application’s executable or batch file. You can use Windows environment variables (%PROGRAMFILES%, %WINDIR%, %SYSTEMROOT%, %USERPROFILE% and others) when specifying the application’s file path and name.

Parameters

The command-line arguments to be passed to the application, if any.

Count

The number of application instances to launch. By default, this parameter is set to 1.

Launch

Specifies whether the application is in the actual launch list, that is, if it is to be launched from the TestedApps project item or TestedApps.RunAll. By default, this parameter is True.

WorkDir

The fully-qualified path to the working folder for the application run, if needed.

Result Value

The zero-based index of the newly added application in the list of tested applications.

Remarks

  • To add iOS applications, use the TestedApps.AddiOSApp method.

  • To add Android applications, use the TestedApps.AddAndroidApp method.

  • To add a ClickOnce application, use the TestedApps.AddClickOnceApp method.

  • To add a Windows Store application, use the TestedApps.AddWinStoreApp method.

  • To add a Java or JavaFX application, use the TestedApps.AddJavaApp method.

  • To add a Java Web Start application, use the TestedApps.AddJavaWebStartApp method.

  • In addition, you can add ClickOnce, AIR, web and Java applications to the list of tested applications by adding the host process that will run the application:

    • For a Java application, specify the path to the Java virtual machine executable as the FullName parameter of the Add method.

    • For an AIR application, specify the path to AIR Debug Launcher’s executable (adl.exe).

    • For a web application, specify the path to the browser’s executable.

    • For a ClickOnce application, specify the name of the Rundll32 executable.

    Use the TestedApp.Params.SimpleParams property to access the host application’s parameters. By using the SimpleParams.CommandLineParameters property, specify command-line arguments that will be used to run the host application:

    • For an AIR application, specify the path to the AIR application’s descriptor file (*.xml).

    • For a Java application, specify the path to the Java application’s jar or class file.

    • For a ClickOnce application, specify the path to the ClickOnce startup file.

    • For a web application, specify the URL of the page to be opened in the browser.

  • Note that the Add method specifies the Simple run mode for the added application. To specify the RunAs, Profile or Debug mode for the added application, you can use the Params property of the TestedApps object.

Example

The following example demonstrates how to add a new application to the TestedApps list and launch it.

JavaScript, JScript

function AddTestedApp()
{

  var FullPath, TestApp, TestAppIndex;
  // Specifies the full path to an application's executable
  FullPath = "C:\\Windows\\system32\\notepad.exe";

  // Adds the application to the collection of tested applications
  TestAppIndex = TestedApps.Add(FullPath);
  Log.Message("A new application has been added to the TestedApps list with the index " + TestAppIndex);

  // Obtains the new tested application and changes its parameters
  TestApp = TestedApps.Items(TestAppIndex);
  // Launches the application
  TestApp.Run();

}

Python

def AddTestedApp():
  # Specifies the full path to an application's executable
  FullPath = "C:\\Windows\\system32\\notepad.exe"

  # Adds the application to the collection of tested applications
  TestAppIndex = TestedApps.Add(FullPath)
  Log.Message("A new application has been added to the TestedApps list with the index "\
     + aqConvert.VarToStr(TestAppIndex))

  # Obtains the new tested application and changes its parameters
  TestApp = TestedApps.Items[TestAppIndex]
  # Launches the application
  TestApp.Run()

VBScript

Sub AddTestedApp

  Dim FullPath, TestApp, TestAppIndex
  ' Specifies the full path to an application's executable
  FullPath = "C:\Windows\system32\notepad.exe"

  ' Adds the application to the collection of tested applications
  TestAppIndex = TestedApps.Add(FullPath)
  Log.Message("A new application has been added to the TestedApps list with the index " & TestAppIndex)

  ' Obtains the new tested application and changes its parameters
  Set TestApp = TestedApps.Items(TestAppIndex)
  ' Launches the application
  TestApp.Run

End Sub

DelphiScript

procedure AddTestedApp();
var FullPath, TestApp, TestAppIndex;
begin

  // Specifies the full path to an application's executable
  FullPath := 'C:\Windows\system32\notepad.exe';

  // Adds the application to the collection of tested applications
  TestAppIndex := TestedApps.Add(FullPath);
  Log.Message('A new application has been added to the TestedApps list with the index ' + aqConvert.IntToStr(TestAppIndex));

  // Obtains the new tested application and changes its parameters
  TestApp := TestedApps.Items(TestAppIndex);
  // Launches the application
  TestApp.Run();

end;

C++Script, C#Script

function AddTestedApp()
{

  var FullPath, TestApp, TestAppIndex;
  // Specifies the full path to an application's executable
  FullPath = "C:\\Windows\\system32\\notepad.exe";

  // Adds the application to the collection of tested applications
  TestAppIndex = TestedApps["Add"](FullPath);
  Log["Message"]("A new application has been added to the TestedApps list with the index " + TestAppIndex);

  // Obtains the new tested application and changes its parameters
  TestApp = TestedApps["Items"](TestAppIndex);
  // Launches the application
  TestApp["Run"]();

}

See Also

Adding Tested Applications
TestedApp Object
Delete Method
Find Method
Items Property
Count Property

Highlight search results