_NewEnum Property

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

Description

The _NewEnum property provides support for enumerating items in the collection that belongs to the given object. This property allows you to use the built-in syntax of the script languages supported by TestComplete to iterate through an object’s collection of items. For example, you can enumerate through objects by using the Utils.Enumerator object or by using language-specific statements: in JavaScript, enumeration is done by using the for...of statement, in JScript, Python, C#Script and C++Script - by using the Enumerator object, and in VBScript - by using the For Each statement.

Declaration

ProgObj._NewEnum

Read-Only Property An Enumerator object
ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section

Applies To

Property Value

An Enumerator object that provides access to the object’s child objects collection.

Example

The following code employs the native script language means of the collection item enumeration to create a list of the names of currently-running processes, one per line, and posts this list to the test log:

JavaScript

function Test()
{
  for (let p of Sys)
  {
    Log.Message(p.Name);
  }
}

JScript

function Test()
{
  var iterator = new Enumerator(Sys);
  for (; !iterator.atEnd(); iterator.moveNext())
  {
    Log.Message(iterator.item().Name);
  }
}

Python

def Test():
  enum = Utils.Enumerator(Sys)

  while not enum.AtEnd:
    Log.Message(enum.Item.Name)
    enum.MoveNext()

VBScript

Sub Test
  Dim p

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

DelphiScript

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

  while not enum.AtEnd do
  begin
    Log.Message(enum.Item.Name);
    enum.MoveNext;
  end;
end;

C++Script, C#Script

function Test()
{
  var iterator = new Enumerator(Sys);
  for (; !iterator["atEnd"](); iterator["moveNext"]())
  {
    Log["Message"](iterator["item"]()["Name"]);
  }
}

See Also

Enumerator Object
Child Method
ChildCount Property

Highlight search results