aqObject.GetMethods Method

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

Description

The GetMethods property returns an aqObjIterator object that lists all the methods 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 methods. Each single method is described by an individual aqObjMethod object.

Declaration

aqObject.GetMethods(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 methods you want to retrieve. If the specified object was not found, the GetMethods 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 methods of the object. Hidden methods 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 aqObjMethod objects that correspond to the methods of the source object.

Example

The code below obtains the names of all the methods of an object corresponding to Notepad's main window and then posts these names to the test log.

JavaScript, JScript

function GetMethodsExample()
{

  // Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL);
  
  // Specifies an object that corresponds
  // to notepad's main window
  var wndNotepad = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1);
  var Obj = wndNotepad.Window("Edit", "", 1);

  // Obtains the collection of methods
  var colMethods = aqObject.GetMethods(Obj);
  
  Log.Message("The methods are:");
  while (colMethods.HasNext())
    Log.Message(colMethods.Next().Name);
  
  // Closes notepad's window
  aqObject.CallMethod(wndNotepad, "Close");
  
}

Python

def GetMethodsExample():
  # Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL)
  # Specifies an object that corresponds
  # to notepad's main window
  wndNotepad = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  Obj = wndNotepad.Window("Edit", "", 1)
  # Obtains the collection of methods
  colMethods = aqObject.GetMethods(Obj)
  Log.Message("The methods are:")
  while colMethods.HasNext():
    Log.Message(colMethods.Next().Name)
  # Closes notepad's window
  aqObject.CallMethod(wndNotepad, "Close")

VBScript

Sub GetMethodsExample

  ' Launches notepad.exe
  Call WshShell.Run("notepad.exe", SW_NORMAL)
  
  ' Specifies an object that corresponds
  ' to notepad's main window
  Set wndNotepad = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  Set Obj = wndNotepad.Window("Edit", "", 1)

  ' Obtains the collection of methods
  Set colMethods = aqObject.GetMethods(Obj)
  
  Log.Message "The methods are:"
  While colMethods.HasNext
    Log.Message(colMethods.Next.Name)
  WEnd
  
  ' Closes notepad's window
  Call aqObject.CallMethod(wndNotepad, "Close")
  
End Sub

DelphiScript

function GetMethodsExample;
var wndNotepad, Obj, colMethods;
begin

  // Launches notepad.exe
  WshShell.Run('notepad.exe', SW_NORMAL);
  
  // Specifies an object that corresponds
  // to notepad's main window
  wndNotepad := Sys.Process('notepad').Window('Notepad', 'Untitled - Notepad', 1);
  Obj := wndNotepad.Window('Edit', '', 1);

  // Obtains the collection of methods
  colMethods := aqObject.GetMethods(Obj);
  
  Log.Message('The methods are:');
  while colMethods.HasNext() do
    Log.Message(colMethods.Next().Name);
  
  // Closes notepad's window
  aqObject.CallMethod(wndNotepad, 'Close');
  
end;

C++Script, C#Script

function GetMethodsExample()
{

  // Launches notepad.exe
  WshShell["Run"]("notepad.exe", SW_NORMAL);
  
  // Specifies an object that corresponds
  // to notepad's main window
  var wndNotepad = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 1);
  var Obj = wndNotepad["Window"]("Edit", "", 1);

  // Obtains the collection of methods
  var colMethods = aqObject["GetMethods"](Obj);
  
  Log["Message"]("The methods are:");
  while ( colMethods["HasNext"]() )
    Log["Message"](colMethods["Next"]()["Name"]);
  
  // Closes notepad's window
  aqObject["CallMethod"]( wndNotepad, "Close" );
  
}

See Also

GetProperties Method
GetMethods Method
GetFields Method
aqObjIterator Object

Highlight search results