aqObject.GetPropertyValue Method

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

Use the GetPropertyValue method to retrieve the value of a particular property of a certain object. If the property requires additional parameters, for example an item index, then they are specified after the property name.

Declaration

aqObject.GetPropertyValue(IObject, PropertyName, Param1, Param2, ...)

IObject [in]    Required    Variant    
PropertyName [in]    Required    String    
Param1 [in]    Optional    Variant    
Param2 [in]    Optional    Variant    
...
Result Variant

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

IObject

The object to which the desired property belongs.

PropertyName

The name of the property whose value you want to get.

If the property with the given name was not found, an error occurs. Use the aqObject.IsSupported method to verify whether the object has a certain property.

Param1, Param2, ..., ParamN

Specify the parameters (if any) required to access the property value.

Result Value

The value of the specified object property.

Example

The code below obtains the value of the wText property of an object corresponding to Notepad's window. After that, the routine posts this value to the test log. Note that in this case, notepad.exe is added to the list of tested applications with the C:\Hello!.txt parameter.

JavaScript, JScript

function GettingPropertyValue()
{

  // Launches notepad.exe with the C:\Hello.txt command line parameter
  WshShell.Run("notepad.exe", SW_NORMAL);
  
  // Specifies an object that corresponds
  // to notepad's window
  var wndNotepad = Sys.Process("notepad").Window("Notepad", "Hello - Notepad", 1);
  var Obj = wndNotepad.Window("Edit", "", 1);
  
  var PropValue = aqObject.GetPropertyValue(Obj, "wText");
  
  // Posts the value of the specified property to the test log
  Log.Message(PropValue);
   
  // Closes notepad's window
  aqObject.CallMethod(wndNotepad, "Close");
  
}

Python

def GettingPropertyValue():
  # Launches notepad.exe with the C:\Hello.txt command line parameter
  WshShell.Run("notepad.exe", SW_NORMAL)
  # Specifies an object that corresponds
  # to notepad's window
  wndNotepad = Sys.Process("notepad").Window("Notepad", "Hello - Notepad", 1)
  Obj = wndNotepad.Window("Edit", "", 1)
  PropValue = aqObject.GetPropertyValue(Obj, "wText")
  # Posts the value of the specified property to the test log
  Log.Message(PropValue)
  # Closes notepad's window
  aqObject.CallMethod(wndNotepad, "Close")

VBScript

Sub GettingPropertyValue

  ' Launches notepad.exe with the C:\Hello.txt command line parameter
  Call WshShell.Run("notepad.exe", SW_NORMAL)
  
  ' Specifies an object that corresponds
  ' to notepad's window
  Set wndNotepad = Sys.Process("notepad").Window("Notepad", "Hello - Notepad", 1)
  Set Obj = wndNotepad.Window("Edit", "", 1)
  
  PropValue = aqObject.GetPropertyValue(Obj, "wText")
  
  ' Posts the value of the specified property to the test log
  Log.Message(PropValue)
   
  ' Closes notepad's window
  Call aqObject.CallMethod(wndNotepad, "Close")
  
End Sub

DelphiScript

function GettingPropertyValue;
var wndNotepad, Obj, PropValue;
begin

  // Launches notepad.exe with the C:\Hello.txt command line parameter
  WshShell.Run('notepad.exe', SW_NORMAL);
  
  // Specifies an object that corresponds
  // to notepad's window
  wndNotepad := Sys.Process('notepad').Window('Notepad', 'Hello - Notepad', 1);
  Obj := wndNotepad.Window('Edit', '', 1);
  
  PropValue := aqObject.GetPropertyValue(Obj, 'wText');
  
  // Posts the value of the specified property to the test log
  Log.Message(PropValue);
   
  // Closes notepad's window
  aqObject.CallMethod(wndNotepad, 'Close');
  
end;

C++Script, C#Script

function GettingPropertyValue()
{

  // Launches notepad.exe with the C:\Hello.txt command line parameter
  WshShell["Run"]("notepad.exe", SW_NORMAL);
  
  // Specifies an object that corresponds
  // to notepad's window
  var wndNotepad = Sys["Process"]("notepad")["Window"]("Notepad", "Hello - Notepad", 1);
  var Obj = wndNotepad["Window"]("Edit", "", 1);
  
  var PropValue = aqObject["GetPropertyValue"](Obj, "wText");
  
  // Posts the value of the specified property to the test log
  Log["Message"](PropValue);
   
  // Closes notepad's window
  aqObject["CallMethod"]( wndNotepad, "Close" );
  
}

See Also

SetPropertyValue Method
IsSupported Method
CallMethod Method
RaiseEvent Method

Highlight search results