FullText Property

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

Description

The FullText property returns all the text recognized in a UI element or image. Individual text blocks are separated with new line symbols.

Declaration

OCRTextDocumentObj.FullText

Read-Only Property String
OCRTextDocumentObj An expression, variable or parameter that specifies a reference to an OCRTextDocument object

Applies To

The property is applied to the following object:

Property Value

A string that represents all the recognized text.

Example

The following example shows how to use optical character recognition to recognize text in the About dialog of Windows Notepad and post the recognized text to the test log.

JavaScript, JScript

function GetRecognizedText()
{
  var p = Sys.WaitProcess("notepad", 3000);
  if (p.Exists)
  {
    // Get the Notepad window
    var wndNotepad = p.WaitWindow("Notepad", "*", 1, 3000);
    if (wndNotepad.Exists)
    {
      wndNotepad.MainMenu.Click("Help|About Notepad");
      // Get the About Notepad window
      var wndAbout = p.WaitWindow("#32770", "About Notepad", 1, 3000);
      if (wndAbout.Exists)
      {
        // Recognize the text that the About Notepad window contains
        var recognizedText = OCR.Recognize(wndAbout);

        // Post the recognized text to the test log
        Log.Message("View all the recognized text in the Details panel", recognizedText.FullText);

        // Post portions of the recognized text to the test log
        if (recognizedText.BlockCount > 0)
        {
          Log.AppendFolder("Recognized text by blocks");
          for (var i = 0; i < recognizedText.BlockCount; i++)
          {
            Log.Message(recognizedText.Block(i).Text);
          }
          Log.PopLogFolder();
        }

      }
    }
  }
  else
  {
    Log.Warning("Notepad is not running.");
  }
}

Python

def GetRecognizedText():
   p = Sys.WaitProcess("notepad", 4000)
   if p.Exists:
     # Get the Notepad window
     wndNotepad = p.WaitWindow("Notepad", "*", 1, 4000)
     if wndNotepad.Exists:
       wndNotepad.MainMenu.Click("Help|About Notepad")
       # Get the About Notepad window
       wndAbout = p.WaitWindow("#32770", "About Notepad", 1, 4000)
       if wndAbout.Exists:
         # Recognize the text that the About Notepad window contains
         recognizedText = OCR.Recognize(wndAbout)

         # Post the recognized text to the test log
         Log.Message("View all the recognized text in the Details panel", recognizedText.FullText)

         # Post portions of the recognized text to the test log
         if recognizedText.BlockCount > 0:
           Log.AppendFolder("Recognized text by blocks")
           for i in range(0, recognizedText.BlockCount):
             Log.Message(recognizedText.Block[i].Text)
           Log.PopLogFolder()

   else:
     Log.Warning("Notepad is not running.")

VBScript

Sub GetRecognizedText
  Set p = Sys.WaitProcess("notepad", 3000)
  If p.Exists Then
    ' Get the Notepad window
    Set wndNotepad = p.WaitWindow("Notepad", "*", 1, 3000)
    If wndNotepad.Exists Then
      wndNotepad.MainMenu.Click("Help|About Notepad")
      ' Get the About Notepad window
      Set wndAbout = p.WaitWindow("#32770", "About Notepad", 1, 3000)
      If wndAbout.Exists Then
        ' Recognize the text that the About Notepad window contains
        Set recognizedText = OCR.Recognize(wndAbout)

        ' Post the recognized text to the test log
        Call Log.Message("View all the recognized text in the Details panel", recognizedText.FullText)

        ' Post portions of the recognized text to the test log
        If recognizedText.BlockCount > 0 Then
          Log.AppendFolder("Recognized text by blocks")
          For i = 0 To recognizedText.BlockCount - 1
            Log.Message(recognizedText.Block(i).Text)
          Next
          Log.PopLogFolder
        End If

      End If
    End If
  Else
    Log.Warning("Notepad is not running.")
  End If
End Sub

DelphiScript

procedure GetRecognizedText();
var p, wndNotepad, wndAbout, recognizedText, i;
begin
  p := Sys.WaitProcess('notepad', 3000);
  if p.Exists then
  begin
    // Get the Notepad window
    wndNotepad := p.WaitWindow('Notepad', '*', 1, 3000);
    if wndNotepad.Exists then
    begin
      wndNotepad.MainMenu.Click('Help|About Notepad');
      // Get the About Notepad window
      wndAbout := p.WaitWindow('#32770', 'About Notepad', 1, 3000);
      if wndAbout.Exists then
      begin
        // Recognize the text that the About Notepad window contains
        recognizedText := OCR.Recognize(wndAbout);

        // Post the recognized text to the test log
        Log.Message('View all the recognized text in the Details panel', recognizedText.FullText);

        // Post portions of the recognized text to the test log
        if recognizedText.BlockCount > 0 then
        begin
          Log.AppendFolder('Recognized text by blocks');
          for i := 0 to recognizedText.BlockCount - 1 do
            Log.Message(recognizedText.Block[i].Text);
          Log.PopLogFolder;
        end;

      end;
    end;
  end  else
    Log.Warning('Notepad is not running.');
end;

C++Script, C#Script

function GetRecognizedText()
{
  var p = Sys["WaitProcess"]("notepad", 3000);
  if (p["Exists"])
  {
    // Get the Notepad window
    var wndNotepad = p["WaitWindow"]("Notepad", "*", 1, 3000);
    if (wndNotepad["Exists"])
    {
      wndNotepad["MainMenu"]["Click"]("Help|About Notepad");
      // Get the About Notepad window
      var wndAbout = p["WaitWindow"]("#32770", "About Notepad", 1, 3000);
      if (wndAbout["Exists"])
      {
        // Recognize the text that the About Notepad window contains
        var recognizedText = OCR["Recognize"](wndAbout);

        // Post the recognized text to the test log
        Log["Message"]("View all the recognized text in the Details panel", recognizedText["FullText"]);

        // Post portions of the recognized text to the test log
        if (recognizedText["BlockCount"] > 0)
        {
          Log["AppendFolder"]("Recognized text by blocks");
          for (var i = 0; i < recognizedText["BlockCount"]; i++)
          {
            Log["Message"](recognizedText["Block"](i)["Text"]);
          }
          Log["PopLogFolder"]();
        }

      }
    }
  }
  else
  {
    Log["Warning"]("Notepad is not running.");
  }
}

See Also

OCRTextDocument Object
Optical Character Recognition

Highlight search results