Naming Processes

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

To provide access to processes, TestComplete uses the process objects. The processes are identified by two parameters:

  • The name of an executable file that starts the process. The file name is used without an extension.

  • The index of a process instance. There can be several running applications with the same name in the system. In this case, the process index is used to distinguish one process instance from another. The first started process has index 1, the second - 2, and so on.

Process Name
Note: The index is an optional parameter for process recognition. If you omit the index when referring to the process, the default value 1 will be used, for example, the names Process("Notepad") and Process("Notepad", 1) are equivalent.

The name of the process object depends on the scripting language that is used in your project. For instance, if you use VBScript, you enclose the executable name in quotes: Process("MyApp"). In DelphiScript, you should use apostrophes instead of quotes, for instance, Process('MyApp'). In JavaScript, JScript and Python, both preceding ways are acceptable. In C#Script and C++Script the word Process should look like ["Process"]. The following sample demonstrates how you can obtain a process in your script code:

JavaScript, JScript

// Obtains the object that provides a scripting interface
// to the second instance of Notepad
var p = Sys.Process("Notepad", 2);

Python

# Obtains the object that provides a scripting interface
# to the second instance of Notepad
p = Sys.Process("Notepad", 2)

VBScript

' Obtains the object that provides a scripting interface
' to the second instance of Notepad
Set p = Sys.Process("Notepad", 2)

DelphiScript

var
  p : OleVariant;
begin
  // Obtains the object that provides a scripting interface
  // to the second instance of Notepad
  p := Sys.Process('Notepad', 2);
end;

C++Script, C#Script

var p;
// Obtains the object that provides a scripting interface
// to the second instance of Notepad
p = Sys["Process"]("Notepad", 2);

Note that the process index can change during the test run: if a process with a lower index is terminated, the higher indexes will be decreased, so the names of other processes are changed.

You can map the process name and address the process via the NameMapping or Aliases objects. See Name Mapping for more information about this.

See Also

Object Browser Naming Notation
About Object Browser Naming Notation
Process Object

Highlight search results