Enumerator Object

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


The Enumerator object maintains a collection of child objects from a test object, for example, the collection of windows belonging to a process, and is available through the _NewEnum property of test objects. Enumerator provides a way to enumerate the child object collection without the need to know the specific types of the child objects. It also enables using intrinsic functions and statements of the scripting languages supported by TestComplete to enumerate this collection. For instance, you can use the for...of statement in JavaScript code, the Enumerator object in JavaScript, JScript, Python, C#Script or C++Script code, the For Each statement in VBScript code or the Utils.Enumerator method available for any scripting language.

You can use the Enumerator properties while exploring an object’s child objects collection in the Object Browser or the Object Spy window. However, these properties are not intended to be used directly in tests. In tests, you enumerate the child objects collection using the Child method and the ChildCount property or using intrinsic functionality of scripting languages (see below).



The following example demonstrates how you can enumerate all running processes on the computer and log their names:


function Test()
  for (let p of Sys)


function Test()
  var iterator = new Enumerator(Sys);
  for (; !iterator.atEnd(); iterator.moveNext())


def Test():
  enum = Enumerator(Sys)

  while not enum.AtEnd:


Sub Test
  Dim p

  For Each p In Sys
    Log.Message p.Name
End Sub


procedure Test;
var enum;
  enum := Utils.Enumerator(Sys);

  while not enum.AtEnd do

C++Script, C#Script

function Test()
  var iterator = new Enumerator(Sys);
  for (; !iterator["atEnd"](); iterator["moveNext"]())

See Also

_NewEnum Property
Child Method
ChildCount Property

Highlight search results