aqObjMethod Object

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

Description

The aqObjMethod object provides a scripting interface to object methods that you can see on the Methods page of the Object Browser panel. To obtain the aqObjMethod object in scripts, use the GetMethods method of the aqObject object.

Note: Actually, the GetMethods method returns an aqObjIterator object that stores information about all found object methods. To get information about a single method, you can use the aqObjIterator.Item and aqObjIterator.Next methods.

Members

Example

The code below obtains the collection of methods that belong to Notepad's main window object and posts the names of these methods to the test log.

JavaScript, JScript

function GettingMethods()
{

  // Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL);
  
  // Specifies the object
  var Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1);
  
  // Obtains the methods collection
  var MethCol = aqObject.GetMethods(Obj);
  
  while (MethCol.HasNext() )
  {
    var Item = MethCol.Next();
    // Posts the method's name to the test log
    Log.Message(Item.Name);
  }
  
  // Closes notepad.exe
  Sys.Process("notepad").Terminate();
    
}

Python

def GettingMethods():
  # Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL)
  # Specifies the object
  Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  # Obtains the methods collection
  MethCol = aqObject.GetMethods(Obj)
  while MethCol.HasNext():
    Item = MethCol.Next()
    # Posts the method's name to the test log
    Log.Message(Item.Name)
  # Closes notepad.exe
  Sys.Process("notepad").Terminate()

VBScript

Sub GettingMethods

  ' Launches notepad.exe
  Call WshShell.Run("notepad.exe", SW_NORMAL)
  
  ' Specifies the object
  Set Obj = Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1)
  
  ' Obtains the methods collection
  Set MethCol = aqObject.GetMethods(Obj)
  
  While MethCol.HasNext
    Set Item = MethCol.Next
    ' Posts the method's name to the test log
    Log.Message(Item.Name)
  WEnd
  
  ' Closes notepad.exe
  Sys.Process("notepad").Terminate
    
End Sub

DelphiScript

function GettingMethods;
var Obj, MethCol, Item;
begin

  // Launches notepad.exe
  WshShell.Run('notepad.exe', SW_NORMAL);
  
  // Specifies the object
  Obj := Sys.Process('notepad').Window('Notepad', 'Untitled - Notepad', 1);
  
  // Obtains the methods collection
  MethCol := aqObject.GetMethods(Obj);
  
  while (MethCol.HasNext() ) do
  begin
    Item := MethCol.Next();
    // Posts the method's name to the test log
    Log.Message(Item.Name);
  end;
  
  // Closes notepad.exe
  Sys.Process('notepad').Terminate();
    
end;

C++Script, C#Script

function GettingMethods()
{

  // Launches notepad.exe
  WshShell["Run"]("notepad.exe", SW_NORMAL);
  
  // Specifies the object
  var Obj = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 1);
  
  // Obtains the methods collection
  var MethCol = aqObject["GetMethods"](Obj);
  
  while (MethCol["HasNext"]() )
  {
    var Item = MethCol["Next"]();
    // Posts the method's name to the test log
    Log["Message"]( Item["Name"] );
  }
  
  // Closes notepad.exe
  Sys["Process"]("notepad")["Terminate"]();
    
}

See Also

aqObjIterator Object

Highlight search results