ChildCount Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use the ChildCount property to obtain the number of child collections of the collection to which StoredObjectObj provides access to. This number does not include the child collection of child collections.

Declaration

StoredObjectObj.ChildCount

Read-Only Property Integer
StoredObjectObj An expression, variable or parameter that specifies a reference to a StoredObject object

Applies To

The property is applied to the following object:

Property Value

An integer value specifying the number of child collections.

Example

The following code demonstrates how you can access the desired property collection and its child collections.

JavaScript, JScript

function Test1()
{
  // Obtains the specified property collection and returns the total number of its child collections
  StoredObject = Objects.Items("MyCollection");
  Log.Message(StoredObject.ChildCount);

  // Obtains a child property collection by its index and returns the collection's name
  ChildCollection = StoredObject.Children(0);
  Log.Message(ChildCollection.Name);

  // Obtains the child property collection by its name
  // ChildCollection = StoredObject.ChildByName("ChildCollectionName");
}

Python

def Test1():
  # Obtains the specified property collection and returns the total number of its child collections 
  StoredObject = Objects.Items("MyCollection")
  Log.Message(StoredObject.ChildCount)
  # Obtains a child property collection by its index and returns the collection's name 
  ChildCollection = StoredObject.Children[0]
  Log.Message(ChildCollection.Name)
  # Obtains the child property collection by its name 
  # ChildCollection = StoredObject.ChildByName("ChildCollectionName")

VBScript

Sub Test1
  ' Obtains the specified property collection and returns the total number of its child collections
  Set StoredObject = Objects.Items("MyCollection")
  Log.Message(StoredObject.ChildCount)

  ' Obtains a child property collection by its index and returns the collection's name
  Set ChildCollection = StoredObject.Children(0)
  Log.Message(ChildCollection.Name)

  ' Obtains the child property collection by its name
  ' Set ChildCollection = StoredObject.ChildByName("ChildCollectionName")
End Sub

DelphiScript

procedure Test1;
begin
  // Obtains the specified property collection and returns the total number of its child collections
  StoredObject := Objects.Items('MyCollection');
  Log.Message(StoredObject.ChildCount);

  // Obtains a child property collection by its index and returns the collection's name
  ChildCollection := StoredObject.Children(0);
  Log.Message(ChildCollection.Name);

  // Obtains the child property collection by its name
  // ChildCollection := StoredObject.ChildByName('ChildCollectionName');
end;

C++Script, C#Script

function Test1()
{
  // Obtains the specified property collection and returns the total number of its child collections
  StoredObject = Objects["Items"]("MyCollection");
  Log["Message"](StoredObject["ChildCount"]);

  // Obtains a child property collection by its index and returns the collection's name
  ChildCollection = StoredObject["Children"](0);
  Log["Message"](ChildCollection["Name"]);

  // Obtains the child property collection by its name
  // ChildCollection = StoredObject["ChildByName"]("ChildCollectionName");
}

See Also

Children Property

Highlight search results