aqObject.GetFields Method

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

Description

The GetFields property returns an aqObjIterator object that lists all the fields of the desired object. Use the aqObjIterator.HasNext, aqObjIterator.Next and aqObjIterator.Item methods of the returned aqObjIterator object to iterate through the collection of the object’s fields. Each single field is described by a separate aqObjField object.

Declaration

aqObject.GetFields(SourceObject, ShowHidden)

SourceObject [in]    Required    Object    
ShowHidden [in]    Optional    Boolean Default value: False   
Result The aqObjIterator object.

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

SourceObject

The object whose fields you want to retrieve. If the specified object was not found, the GetFields method returns an empty value (that is, Nothing in VBScript, null in JavaScript, JScript, C++Script and C#Script, None in Python and nil in DelphiScript).

ShowHidden

Specifies whether to retrieve hidden fields of the object. Hidden fields are those that are displayed in the Object Browser but are not listed in the Code Completion window.

Result Value

The aqObjIterator object whose items are aqObjField objects that correspond to the fields of the source object.

Example

The code below obtains the collection of fields that belong to the object corresponding to the toolbar of the sample Orders application. Note that for the correct script execution, you need to open the Orders application first.

JavaScript, JScript

function GettingFields()
{

  var Obj = Sys.Process("Orders").WinFormsObject("MainForm").WinFormsObject("ToolBar");
  
  // Obtains the fields collection
  var FieldsCol = aqObject.GetFields(Obj);
  
  Log.Message("The fields are:");
  
  // Posts the fields names to the test log
  while ( FieldsCol.HasNext() )
    Log.Message( FieldsCol.Next().Name );
  
}

Python

def GettingFields():
  Obj = Sys.Process("Orders").WinFormsObject("MainForm").WinFormsObject("ToolBar")
  # Obtains the fields collection
  FieldsCol = aqObject.GetFields(Obj)
  Log.Message("The fields are:")
  # Posts the fields names to the test log
  while FieldsCol.HasNext():
    Log.Message(FieldsCol.Next().Name)

VBScript

Sub GettingFields

  Set Obj = Sys.Process("Orders").WinFormsObject("MainForm").WinFormsObject("ToolBar")
  
  ' Obtains the fields collection
  Set FieldsCol = aqObject.GetFields(Obj)
  
  Log.Message "The fields are:"
  
  ' Posts the fields names to the test log
  While FieldsCol.HasNext
    Log.Message FieldsCol.Next.Name
  WEnd
  
End Sub

DelphiScript

function GettingFields;
var Obj, FieldsCol;
begin

  Obj := Sys.Process('Orders').WinFormsObject('MainForm').WinFormsObject('ToolBar');
  
  // Obtains the fields collection
  FieldsCol := aqObject.GetFields(Obj);
  
  Log.Message('The fields are:');
  
  // Posts the fields names to the test log
  while ( FieldsCol.HasNext() ) do
    Log.Message( FieldsCol.Next().Name );
  
end;

C++Script, C#Script

function GettingFields()
{

  var Obj = Sys["Process"]("Orders")["WinFormsObject"]("MainForm")["WinFormsObject"]("ToolBar");
  
  // Obtains the fields collection
  var FieldsCol = aqObject["GetFields"](Obj);
  
  Log["Message"]("The fields are:");
  
  // Posts the fields names to the test log
  while ( FieldsCol["HasNext"]() )
    Log["Message"]( FieldsCol["Next"]()["Name"] );
  
}

See Also

GetProperties Method
GetMethods Method
GetEvents Method
aqObjIterator Object

Highlight search results