TextObject Object

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

Description

The TextObject object provides a scripting interface to objects that are exposed by the Text Recognition technology. These objects are identified by text that they display.

Members

Example

The following example demonstrates how to obtain the TextObject in script:

JavaScript, JScript

function Test()
{
  var process, window, TextObject;
  // Obtains the process and the window of the tested application
  process = Sys.Process("SampleApp");
  window = process.Window("*", "SampleApp")

  // Obtains the object exposed by the Text Recognition plugin and specified by its text and index
  TextObject = window.TextObject("SampleText", 3);

  // Checks if the object has been obtained successfully
  if (TextObject.Exists)
    Log.Message("The required text object is found.")
  else
    Log.Error("The required text object is not found.");
}

Python

def Test():
  # Obtains the process and the window of the tested application 
  process = Sys.Process("MyApp")
  window = process.Window("*", "MyApp", 1)
  # Obtains the object exposed by the Text Recognition plugin and specified by its text and index 
  TextObject = window.TextObject("SampleText", 3)

  # Checks if the object has been obtained successfully 
  if TextObject.Exists:
    Log.Message("The required text object is found.")
  else:
    Log.Error("The required text object is not found.")

VBScript

Sub Test

  Dim process, window, TextObject
  ' Obtains the process and the window of the tested application
  Set process = Sys.Process("SampleApp")
  Set window = process.Window("*", "SampleApp")

  ' Obtains the object exposed by the Text Recognition plugin and specified by its text and index
  Set TextObject = window.TextObject("SampleText", 3)

  ' Checks if the object has been obtained successfully
  If TextObject.Exists Then
    Log.Message("The required text object is found.")
  Else
    Log.Error("The required text object is not found.")
  End If
End Sub

DelphiScript

procedure Test();
var process, window, TextObject;
begin
  // Obtains the process and the window of the tested application
  process := Sys.Process('SampleApp');
  window := process.Window('*', 'SampleApp');

  // Obtains the object exposed by the Text Recognition plugin and specified by its text and index
  TextObject := window.TextObject('SampleText', 3);

  // Checks if the object has been obtained successfully
  if TextObject.Exists then
    Log.Message('The required text object is found.')
  else
    Log.Error('The required text object is not found.');
end;

C++Script, C#Script

function Test()
{
  var process, window, TextObject;
  // Obtains the process and the window of the tested application
  process = Sys["Process"]("SampleApp");
  window = process["Window"]("*", "SampleApp")

  // Obtains the object exposed by the Text Recognition plugin and specified by its text and index
  TextObject = window["TextObjec"]("SampleText", 3);

  // Checks if the object has been obtained successfully
  if (TextObject["Exists"])
    Log["Message"]("The required text object is found.")
  else
    Log["Error"]("The required text object is not found.");
}

See Also

Onscreen Object
Using Text Recognition Technology - Overview

Highlight search results