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 PropertyDeclaration.Value
property to get or set the default value of the ODT class property from scripts. Note that if you modify the default value of a class property, the corresponding property value will also be modified in all objects that are based on this class and on the conditions that you have not changed in the object’s property, since the object was created.
Declaration
PropertyDeclarationObj.Value
Read-Write Property | Variant |
PropertyDeclarationObj | An expression, variable or parameter that specifies a reference to a PropertyDeclaration object |
Applies To
The property is applied to the following object:
Property Value
The value that is to be used as a default for the specified property. It can be any OLEVariant-compatible value: string, integer, class, array, and so on, except OLE objects. See the Remarks section for details.
Remarks
The Value
property is used by default in the PropertyDeclaration
object, so you can omit it when addressing the item value. For instance, the following two lines are equivalent:
JavaScript, JScript
MyClass.MyProperty = 10;
VBScript
MyClass.MyProperty = 10
DelphiScript
MyClass.MyProperty := 10;
C++Script, C#Script
MyClass["MyProperty"] = 10;
When specifying property values of ODT classes, you cannot assign objects to them, except for those objects that are ODT arrays and classes. Other objects, for example process
or window
objects, cannot be ODT class property values.
You can only assign object values to properties of class instances, that is Object
objects created using the Classes.New
method. Note that in this case, you are working with a Property
object that provides access to object properties in scripts.
The following code illustrates this restriction:
JavaScript
let w = Sys.Process("App").Window("WndClass", "WndCaption");
let oClass = ODT.Classes.Items("MyClass"); // Obtaining an ODT class
oClass.$set("Properties", "MyProperty", w); // Incorrect!!! oClass is a class declaration
let oObj = ODT.Classes.New("MyClass"); // Creating a class instance
oObj.$set("Properties", "MyProperty", w); // Correct: oObj is a class instance
JScript
var w = Sys.Process("App").Window("WndClass", "WndCaption");
var oClass = ODT.Classes.Items("MyClass"); // Obtaining an ODT class
oClass.Properties("MyProperty") = w; // Incorrect!!! oClass is a class declaration
var oObj = ODT.Classes.New("MyClass"); // Creating a class instance
oObj.Properties("MyProperty") = w; // Correct: oObj is a class instance
VBScript
Set w = Sys.Process("App").Window("WndClass", "WndCaption")
Set oClass = ODT.Classes.Items("MyClass") ' Obtaining an ODT class
Set oClass.Properties("MyProperty") = w ' Incorrect!!! oClass is a class declaration
Set oObj = ODT.Classes.New("MyClass") ' Creating a class instance
Set oObj.Properties("MyProperty") = w ' Correct: oObj is a class instance
DelphiScript
var
w, oClass, oObj: OleVariant;
...
w := Sys.Process('App').Window('WndClass', 'WndCaption');
oClass := ODT.Classes.Items('MyClass'); // Obtaining an ODT class
oClass.Properties('MyProperty') := w; // Incorrect!!! oClass is a class declaration
oObj := ODT.Classes.New('MyClass'); // Creating a class instance
oObj.Properties('MyProperty') := w; // Correct: oObj is a class instance
C++Script, C#Script
var w = Sys["Process"]("App")["Window"]("WndClass", "WndCaption");
var oClass = ODT["Classes"]["Items"]("MyClass"); // Obtaining an ODT class
oClass["Properties"]("MyProperty") = w; // Incorrect!!! oClass is a class declaration
var oObj = ODT["Classes"]["New"]("MyClass"); // Creating a class instance
oObj["Properties"]("MyProperty") = w; // Correct: oObj is a class instance
Example
The following example demonstrates how to obtain the property declaration and change the default property value in script.
JavaScript, JScript
{
var SampleClass, PropDeclObj;
// Obtains the existing class by its name
SampleClass = ODT.Classes.Items("SampleClass");
// Obtains the declaration of the class property
PropDeclObj = SampleClass.Properties("PropertyName");
// Specifies the property’s new default value
PropDeclObj.Value = 10;
}
VBScript
Dim SampleClass, PropDeclObj
' Obtains the existing class by its name
Set SampleClass = ODT.Classes.Items("SampleClass")
' Obtains the declaration of the class property
Set PropDeclObj = SampleClass.Properties("PropertyName")
' Specifies the property’s new default value
PropDeclObj.Value = 10
End Sub
DelphiScript
var SampleClass, PropDeclObj;
begin
// Obtains the existing class by its name
SampleClass := ODT.Classes.Items('SampleClass');
// Obtains the declaration of the class property
PropDeclObj := SampleClass.Properties('PropertyName');
// Specifies the property’s new default value
PropDeclObj.Value := 10;
end;
C++Script, C#Script
{
var SampleClass, PropDeclObj;
// Obtains the existing class by its name
SampleClass = ODT["Classes"]["Items"]("SampleClass");
// Obtains the declaration of the class property
PropDeclObj = SampleClass["Properties"]("PropertyName");
// Specifies the property’s new default value
PropDeclObj["Value"] = 10;
}