Process Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The Process method returns a Process object by its application name and index. If the process is not found, the method returns an empty object and posts the message “The process … was not found” to the test log. You can call Exists to determine whether the returned object is a process in the system. To obtain the process object without posting any messages to the test log, use Sys.WaitProcess or WaitChild.

The Process method does not launch the specified process. It simply searches for it among all processes that currently exist in the system.

Usually, there are several application processes running in the system. Each of them runs an application with a unique name, but there can be several instances of the application running at the same time. They will have the same application name but different process indexes. The first instance will have index 1, the second, 2, etc. If ProcessIndex is omitted, it is regarded as 1. If you obtain several processes with the same name and the process with the lowest index is terminated, the indexes of other processes will be decreased by one.

Once you obtain the process object, you can test its UI. If the application is an Open Application, you can use the Process object to access application objects, their methods and properties.

Declaration

TestObj.Process(ProcessName, ProcessIndex)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ProcessName [in]    Required    String    
ProcessIndex [in]    Optional    Integer Default value: 1   
Result A Process object

Applies To

The method is applied to the following object:

Sys

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameters:

ProcessName

Specifies the name of the process you want to get.

ProcessIndex

Specifies the index of the process you want to get.

Result Value

A Process object that provides access to the specified application.

Example

The following example demonstrates how to use the Process method in scripts:

JavaScript, JScript

var p = Sys.Process("Notepad");

Python

p = Sys.Process("Notepad")

VBScript

Set p = Sys.Process("Notepad")

DelphiScript

var p;
begin
  p := Sys.Process('Notepad');

end;

C++Script, C#Script

var p = Sys["Process"]("Notepad")

See Also

WaitProcess Method
Process Object
ProcessName Property
Index Property (Process and Browser Objects)

Highlight search results