ClassRef Property

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

The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.

Description

Use the ArrayObject.ClassRef property to get a reference to the ArrayType object on which ArrayObject is based.

Declaration

ArrayObjectObj.ClassRef

Read-Only Property An ArrayType object
ArrayObjectObj An expression, variable or parameter that specifies a reference to an ArrayObject object

Applies To

The property is applied to the following object:

Property Value

A reference to the ArrayType object.

Example

The code below creates a new class and adds the MyProperty property to it. Then the routine creates a data object that belongs to the created class and changes the value of the MyProperty property. After that, the code compares the value of the property stored in the data object with the value of the same property stored in the parent class and checks whether the value has changed.

JavaScript

function ClassRef()
{
  // Declares a class and adds a new property to it
  let ObjNew = ODT.Classes.Declare("TestClass");
  let Prop1 = ObjNew.AddProperty("MyProperty", 123);
  
  // Specifies the object that belongs to the created class
  let Data = ODT.Data.AddGroup("TestData").AddVarOfClassType("MyVariable", "TestClass");
  // Changes the value of the MyProperty property
  Data.$set("Properties", 0, 124);
  // Checks whether the property's value has changed
  if ( equal(Data.Properties(0).Value, Data.ClassRef.Properties(0)) )
    Log.Message("The value of the MyProperty property was not changed.");
  else 
     Log.Message("The value of the MyProperty property was changed.");
}

JScript

function ClassRef()
{
   // Declares a class and adds a new property to it
   var ObjNew = ODT.Classes.Declare("TestClass");
   var Prop1 = ObjNew.AddProperty("MyProperty", 123);
   
   // Specifies the object that belongs to the created class
   var Data = ODT.Data.AddGroup("TestData").AddVarOfClassType("MyVariable", "TestClass");
   // Changes the value of the MyProperty property
   Data.Properties(0) = 124;
   // Checks whether the property's value has changed
   if ( Data.Properties(0).Value == Data.ClassRef.Properties(0) )
     Log.Message("The value of the MyProperty property was not changed.")
   else 
     Log.Message("The value of the MyProperty property was changed.");
}

VBScript

Sub ClassRef
   ' Declares a class and adds a new property to it
   Set ObjNew = ODT.Classes.Declare("TestClass")
   Set Prop1 = ObjNew.AddProperty("MyProperty", 123)
   
   ' Specifies the object that belongs to the created class
   Set Data = ODT.Data.AddGroup("TestData").AddVarOfClassType("MyVariable", "TestClass")
   ' Changes the value of the MyProperty property
   Data.Properties(0) = 124
   ' Checks whether the property's value has changed
   If Data.Properties(0).Value = Data.ClassRef.Properties(0) Then
     Log.Message("The value of the MyProperty property was not changed.")
   Else 
     Log.Message("The value of the MyProperty property was changed.")
   End If
End Sub

DelphiScript

function ClassRef;
var ObjNew, Prop1, Data;
begin
   // Declares a class and adds a new property to it
   ObjNew := ODT.Classes.Declare('TestClass');
   Prop1 := ObjNew.AddProperty('MyProperty', 123);
   
   // Specifies the object that belongs to the created class
   Data := ODT.Data.AddGroup('TestData').AddVarOfClassType('MyVariable', 'TestClass');
   // Changes the value of the MyProperty property
   Data.Properties(0) := 124;
   // Checks whether the property's value has changed
   if ( Data.Properties(0).Value = Data.ClassRef.Properties(0) ) then
     Log.Message('The value of the MyProperty property was not changed.')
   else
     Log.Message('The value of the MyProperty property was changed.');
end;

C++Script, C#Script

function ClassRef()
{
   // Declares a class and adds a new property to it
   var ObjNew = ODT["Classes"]["Declare"]("TestClass");
   var Prop1 = ObjNew["AddProperty"]("MyProperty", 123);
   
   // Specifies the object that belongs to the created class
   var Data = ODT["Data"]["AddGroup"]("TestData")["AddVarOfClassType"]("MyVariable", "TestClass");
   // Changes the value of the MyProperty property
   Data["Properties"](0) = 124;
   // Checks whether the property's value has changed
   if ( Data["Properties"](0)["Value"] == Data["ClassRef"]["Properties"](0) )
     Log["Message"]("The value of the MyProperty property was not changed.")
   else 
     Log["Message"]("The value of the MyProperty property was changed.");
}

Highlight search results