Children Property

Applies to TestComplete 15.20, last modified on January 19, 2022

Description

Use the Children property to obtain a scripting interface to a child property collection of the collection to which StoredObject provides access to.

Declaration

StoredObjectObj.Children(Index)

Read-Only Property A StoredObject object
StoredObjectObj An expression, variable or parameter that specifies a reference to a StoredObject object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

Specifies the index of the desired child collection in the collection to which StoredObjectObj provides access to. The first child collection has index 0, the second - 1, the third - 2, and so forth. The total number of child collections is returned by the ChildCount property.

Property Value

A StoredObject object that provides a scripting interface to a child property collection.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the StoredObjectObj.Children property in square brackets: StoredObjectObj.Children[Index].

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

ChildCount Property
ChildByName Property

Highlight search results