aqObject.SetPropertyValue Method

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

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

Declaration

aqObject.SetPropertyValue(IObject, PropertyName, Param1, Param2, ..., ParamN, PropertyValue)

IObject [in]    Required    Variant    
PropertyName [in]    Required    String    
Param1, Param2, ..., ParamN [in]    Optional    Variant    
PropertyValue [in]    Required    Variant    
Result Boolean

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 set.

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

Use these parameters if the property is an indexed property, like Item[Index]. These parameters specify the values (indexes) required to access the values of these properties. If your property is not an indexed property, skip these parameters.

PropertyValue

Specifies the value to be assigned to the property.

Result Value

True if the value was set successfully, and False otherwise.

Example

The code below checks whether the PropertyName property is supported by the specified object. If it is, the routine sets a new value for this property. Otherwise, an error occurs.

JavaScript, JScript

function SettingPropertyValue()
{

   var app = Sys.Process("MyApplication");
   var prop = "PropertyName";
   
   // Checks whether the desired property is supported
   if ( aqObject.IsSupported(app, prop) )
      aqObject.SetPropertyValue(app, prop, "PropertyValue")
   else
      Log.Error("The specified property is not supported by the object.");
    
}

Python

def SettingPropertyValue():
  app = Sys.Process("MyApplication")
  prop = "PropertyName"
  # Checks whether the desired property is supported
  if aqObject.IsSupported(app, prop):
    aqObject.SetPropertyValue(app, prop, "PropertyValue")
  else:
    Log.Error("The specified property is not supported by the object.")

VBScript

Sub SettingPropertyValue

   Set app = Sys.Process("MyApplication")
   prop = "PropertyName"
   
   ' Checks whether the desired property is supported
   If aqObject.IsSupported(app, prop) Then 
      Call aqObject.SetPropertyValue(app, prop, "PropertyValue")
   Else
      Log.Error "The specified property is not supported by the object."
   End If
    
End Sub

DelphiScript

function SettingPropertyValue;
var app, prop;
begin

   app := Sys.Process('MyApplication');
   prop := 'PropertyName';
   
   // Checks whether the desired property is supported
   if ( aqObject.IsSupported(app, prop) ) then
      aqObject.SetPropertyValue(app, prop, 'PropertyValue')
   else
      Log.Error('The specified property is not supported by the object.');
    
end;

C++Script, C#Script

function SettingPropertyValue()
{

   var app = Sys["Process"]("MyApplication");
   var prop = "PropertyName";
   
   // Checks whether the desired property is supported
   if ( aqObject["IsSupported"]( app, prop ) )
      aqObject["SetPropertyValue"]( app, prop, "PropertyValue" )
   else
      Log["Error"]("The specified property is not supported by the object.");
    
}

See Also

GetPropertyValue Method
CallMethod Method
RaiseEvent Method

Highlight search results