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 Object.Owner
property to get the object that has a reference to the Object object.
Declaration
ObjectObj.Owner
Read-Only Property | Variant |
ObjectObj | An expression, variable or parameter that specifies a reference to an Object object |
Applies To
The property is applied to the following object:
Property Value
The object that has a reference to the given object.
Example
The following code snippet demonstrates how you can use the Owner
property to obtain the object that has a reference to the current object.
JavaScript, JScript
function ObjectSample()
{
ODT.Data.Clear();
ODT.Classes.Clear();
var NewClass, TestGroup, TestVar, Prop;
// Declares a new class
NewClass = ODT.Classes.Declare("NewClass");
NewClass.AddProperty("Property1", "Value1");
// Adds a data group
TestGroup = ODT.Data.AddGroup("TestGroup");
// Creates a variable of the NewClass type in the data group
TestVar = TestGroup.AddVarOfClassType("TestVar", "NewClass");
// Adds a property of the NewClass type to the variable
Prop = TestVar.AddPropOfClassType("TestProperty", "NewClass");
// Uses the Owner property to obtain the TestVar object
// And adds a new property to the TestVar object
Prop.Owner.AddProperty("NewProperty");
// Posts TestVar’s property names to the test log
Log.AppendFolder("TestVar variable’s properties:");
for (var i = 0; i < TestVar.PropertyCount; i++)
Log.Message(TestVar.Properties(i).Name)
Log.PopLogFolder();
}
{
ODT.Data.Clear();
ODT.Classes.Clear();
var NewClass, TestGroup, TestVar, Prop;
// Declares a new class
NewClass = ODT.Classes.Declare("NewClass");
NewClass.AddProperty("Property1", "Value1");
// Adds a data group
TestGroup = ODT.Data.AddGroup("TestGroup");
// Creates a variable of the NewClass type in the data group
TestVar = TestGroup.AddVarOfClassType("TestVar", "NewClass");
// Adds a property of the NewClass type to the variable
Prop = TestVar.AddPropOfClassType("TestProperty", "NewClass");
// Uses the Owner property to obtain the TestVar object
// And adds a new property to the TestVar object
Prop.Owner.AddProperty("NewProperty");
// Posts TestVar’s property names to the test log
Log.AppendFolder("TestVar variable’s properties:");
for (var i = 0; i < TestVar.PropertyCount; i++)
Log.Message(TestVar.Properties(i).Name)
Log.PopLogFolder();
}
VBScript
Sub ObjectSample
ODT.Data.Clear
ODT.Classes.Clear
' Declares a new class
Set NewClass = ODT.Classes.Declare("NewClass")
Call NewClass.AddProperty("Property1", "Value1")
' Adds a data group
Set TestGroup = ODT.Data.AddGroup("TestGroup")
' Creates a variable of the NewClass type in the data group
Set TestVar = TestGroup.AddVarOfClassType("TestVar", "NewClass")
' Adds a property of the NewClass type to the variable
Set Prop = TestVar.AddPropOfClassType("TestProperty", "NewClass")
' Uses the Owner property to obtain the TestVar object
' And adds a new property to the TestVar object
Call Prop.Owner.AddProperty("NewProperty")
' Posts TestVar’s property names to the test log
Log.AppendFolder "TestVar variable’s properties:"
For i = 0 To TestVar.PropertyCount - 1
Log.Message TestVar.Properties(i).Name
Next
Log.PopLogFolder
End Sub
ODT.Data.Clear
ODT.Classes.Clear
' Declares a new class
Set NewClass = ODT.Classes.Declare("NewClass")
Call NewClass.AddProperty("Property1", "Value1")
' Adds a data group
Set TestGroup = ODT.Data.AddGroup("TestGroup")
' Creates a variable of the NewClass type in the data group
Set TestVar = TestGroup.AddVarOfClassType("TestVar", "NewClass")
' Adds a property of the NewClass type to the variable
Set Prop = TestVar.AddPropOfClassType("TestProperty", "NewClass")
' Uses the Owner property to obtain the TestVar object
' And adds a new property to the TestVar object
Call Prop.Owner.AddProperty("NewProperty")
' Posts TestVar’s property names to the test log
Log.AppendFolder "TestVar variable’s properties:"
For i = 0 To TestVar.PropertyCount - 1
Log.Message TestVar.Properties(i).Name
Next
Log.PopLogFolder
End Sub
DelphiScript
procedure ObjectSample();
var NewClass, TestGroup, TestVar, Prop, i;
begin
ODT.Data.Clear();
ODT.Classes.Clear();
// Declares a new class
NewClass := ODT.Classes.Declare('NewClass');
NewClass.AddProperty('Property1', 'Value1');
// Adds a data group
TestGroup := ODT.Data.AddGroup('TestGroup');
// Creates a variable of the NewClass type in the data group
TestVar := TestGroup.AddVarOfClassType('TestVar', 'NewClass');
// Adds a property of the NewClass type to the variable
Prop := TestVar.AddPropOfClassType('TestProperty', 'NewClass');
// Uses the Owner property to obtain the TestVar object
// And adds a new property to the TestVar object
Prop.Owner.AddProperty('NewProperty');
// Posts TestVar’s property names to the test log
Log.AppendFolder('TestVar variable''s properties:');
for i := 0 to TestVar.PropertyCount - 1 do
Log.Message(TestVar.Properties[i].Name);
Log.PopLogFolder();
end;
var NewClass, TestGroup, TestVar, Prop, i;
begin
ODT.Data.Clear();
ODT.Classes.Clear();
// Declares a new class
NewClass := ODT.Classes.Declare('NewClass');
NewClass.AddProperty('Property1', 'Value1');
// Adds a data group
TestGroup := ODT.Data.AddGroup('TestGroup');
// Creates a variable of the NewClass type in the data group
TestVar := TestGroup.AddVarOfClassType('TestVar', 'NewClass');
// Adds a property of the NewClass type to the variable
Prop := TestVar.AddPropOfClassType('TestProperty', 'NewClass');
// Uses the Owner property to obtain the TestVar object
// And adds a new property to the TestVar object
Prop.Owner.AddProperty('NewProperty');
// Posts TestVar’s property names to the test log
Log.AppendFolder('TestVar variable''s properties:');
for i := 0 to TestVar.PropertyCount - 1 do
Log.Message(TestVar.Properties[i].Name);
Log.PopLogFolder();
end;
C++Script, C#Script
function ObjectSample()
{
ODT["Data"]["Clear"]();
ODT["Classes"]["Clear"]();
var NewClass, TestGroup, TestVar, Prop;
// Declares a new class
NewClass = ODT["Classes"]["Declare"]("NewClass");
NewClass["AddProperty"]("Property1", "Value1");
// Adds a data group
TestGroup = ODT["Data"]["AddGroup"]("TestGroup");
// Creates a variable of the NewClass type in the data group
TestVar = TestGroup["AddVarOfClassType"]("TestVar", "NewClass");
// Adds a property of the NewClass type to the variable
Prop = TestVar["AddPropOfClassType"]("TestProperty", "NewClass");
// Uses the Owner property to obtain the TestVar object
// And adds a new property to the TestVar object
Prop["Owner"]["AddProperty"]("NewProperty");
// Posts TestVar’s property names to the test log
Log["AppendFolder"]("TestVar variable’s properties:");
for (var i = 0; i < TestVar["PropertyCount"]; i++)
Log["Message"](TestVar["Properties"](i)["Name"])
Log["PopLogFolder"]();
}
{
ODT["Data"]["Clear"]();
ODT["Classes"]["Clear"]();
var NewClass, TestGroup, TestVar, Prop;
// Declares a new class
NewClass = ODT["Classes"]["Declare"]("NewClass");
NewClass["AddProperty"]("Property1", "Value1");
// Adds a data group
TestGroup = ODT["Data"]["AddGroup"]("TestGroup");
// Creates a variable of the NewClass type in the data group
TestVar = TestGroup["AddVarOfClassType"]("TestVar", "NewClass");
// Adds a property of the NewClass type to the variable
Prop = TestVar["AddPropOfClassType"]("TestProperty", "NewClass");
// Uses the Owner property to obtain the TestVar object
// And adds a new property to the TestVar object
Prop["Owner"]["AddProperty"]("NewProperty");
// Posts TestVar’s property names to the test log
Log["AppendFolder"]("TestVar variable’s properties:");
for (var i = 0; i < TestVar["PropertyCount"]; i++)
Log["Message"](TestVar["Properties"](i)["Name"])
Log["PopLogFolder"]();
}