Index Property (TextObject Objects)

Applies to TestComplete 14.80, last modified on April 13, 2021

Description

Use this property to obtain the position (index) of the window element in the onscreen control or window to which this element belongs.

The value of the Index property is included in the name of the TextObject object associated with the window element if this property value is 1 and the text of the window element coincides with the text of other window elements, or if the value of the Index property greater than 1.

If the value of the Index property is 1 and there are no other window elements with the same caption, the index is omitted in the TextObject name.

Declaration

TestObj.Index

Read-Only Property Integer
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following object:

View Mode

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

Property Value

An integer value that specifies the object position on the window.

Example

The following example demonstrates how to obtain the index of an element associated with TextObject.

JavaScript, JScript

function Test()
{
  var process, window, TextObject;
  // Obtains the process and window of the tested application
  process = Sys.Process("SampleApp");
  window = process.Window("*", "Sample");
  // Obtains the object exposed by the Text Recognition plugin
  TextObject = window.TextObject("SampleText");
  // Posts the index of the obtained object to the test log
  Log.Message("The index of the object is " + TextObject.Index);

}

Python

def Test():
  # Obtains the process and window of the tested application
  process = Sys.Process("SampleApp")
  window = process.Window("*", "Sample")
  # Obtains the object exposed by the Text Recognition plugin
  TextObject = window.TextObject("SampleText")
  # Posts the index of the obtained object to the test log
  Log.Message("The index of the object is " + str(TextObject.Index))

VBScript

Sub Test

  Dim process, window, TextObject
  ' Obtains the process and window of the tested application
  Set process = Sys.Process("SampleApp")
  Set window = process.Window("*", "Sample")
  ' Obtains the object exposed by the Text Recognition plugin
  Set TextObject = window.TextObject("SampleText")
  ' Posts the index of the obtained object to the test log
  Log.Message("The index of the object is " & TextObject.Index)

End Sub

DelphiScript

procedure Test();
var process, window, TextObject;
begin
  // Obtains the process and window of the tested application
  process := Sys.Process('SampleApp');
  window := process.Window('*', 'Sample');
  // Obtains the object exposed by the Text Recognition plugin
  TextObject := window.TextObject('SampleText');
  // Posts the index of the obtained object to the test log
  Log.Message('The index of the object is ' + aqConvert.IntToStr(TextObject.Index));

end;

C++Script, C#Script

function Test()
{
  var process, window, TextObject;
  // Obtains the process and window of the tested application
  process = Sys["Process"]("SampleApp");
  window = process["Window"]("*", "Sample");
  // Obtains the object exposed by the Text Recognition plugin
  TextObject = window["TextObject"]("SampleText");
  // Posts the index of the obtained object to the test log
  Log["Message"]("The index of the object is " + TextObject["Index"]);

}

See Also

TextObject Object
Using Text Recognition Technology - Overview

Highlight search results