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 Property.Name
property to specify the property name. Note that you cannot rename an object property if it was defined in a class. At the “object” level, you can rename only those properties that you added to the object using the AddProperty
method after the object was created.
Declaration
PropertyObj.Name
Read-Write Property | String |
PropertyObj | An expression, variable or parameter that specifies a reference to a Property object |
Applies To
The property is applied to the following object:
Property Value
A string that holds the property name.
Remarks
When changing this property, keep in mind that the property name must be unique within the class or object to which the property belongs. If the class or object already contains another method or property with the same name, an error will occur. Also, the property name is used to refer to the property in scripts. Therefore, the property name must match the naming rules of the project’s scripting languages (it must be a valid identifier). Otherwise, the scripts will not work.
Example
The following example demonstrates how to get access to an object’s property and obtain the property’s name.
JavaScript, JScript
{
var PropertyObj, Obj, Name;
// Creates an object
Obj = ODT.Classes.New("SampleClass");
// Gets access to the object’s property
PropertyObj = Obj.Properties(0);
// Obtains the property’s name
Name = PropertyObj.Name;
Log.Message(Name);
…
}
VBScript
Dim PropertyObj, Obj
' Creates an object
Set Obj = ODT.Classes.New("SampleClass")
' Gets access to the object’s property
Set PropertyObj = Obj.Properties(0)
' Obtains the property’s name
Name = PropertyObj.Name
Log.Message Name
…
End Sub
DelphiScript
var PropertyObj, Obj, Name;
begin
// Creates an object
Obj := ODT.Classes.New('SampleClass');
// Gets access to the object’s property
PropertyObj := Obj.Properties[0];
// Obtains the property’s name
Name := PropertyObj.Name;
Log.Message(Name);
…
end;
C++Script, C#Script
{
var PropertyObj, Obj, Name;
// Creates an object
Obj = ODT["Classes"]["New"]("SampleClass");
// Gets access to the object’s property
PropertyObj = Obj["Properties"](0);
// Obtains the property’s name
Name = PropertyObj["Name"];
Log["Message"](Name);
…
}