How to Create, Modify and Delete Properties

Applies to TestComplete 14.60, last modified on April 22, 2021

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.

You can add and modify properties both in classes and in objects. This section explains how to work with properties in classes. You can create, rename, delete and modify properties in objects in a similar manner.

We would like to draw your attention to the following principles used when working with properties:

  • When you add a property to a class, the property is also added to all objects that are based on this class. When you add a property to an object, it is added to the object only.
  • When you modify the value of a property in a class, the property value is modified in all objects, which are based on this class, on conditions that you have not modified this property since the object creation. The same concerns property renaming: if you rename a property in a class, it is also renamed in all objects that are based on this class.
  • Property names must match the naming rules of the project scripting language. For information on this, see below.
  • All properties are public.

To add a new property

  1. If you want to add a new property to a class, select the class in the ODT | Classes branch of the ODT editor or in the Classes tree of the Classes editor. If you want to add a new property to an object, select the object in the object hierarchy displayed in the ODT | Data branch of the ODT editor or in the Data tree of the Data editor.
  2. Right-click the chosen class.
  3. Select New Item from the context menu.
  4. TestComplete will create a new property and give it a simple name like NewProperty1. You can then rename the property and specify its value (see below for more information on this).
Names of properties are used for referring to properties in scripts and keyword tests. That is why these names must consist of the A..Z, a..z, 0..9 and _ characters only (that is, they must be valid identifiers in the scripting language you use). The property names are case-sensitive in JScript, C++Script and C#Script scripts, and case-insensitive in VBScript and DelphiScript scripts.

To rename a property

  1. If you want to rename the desired property in the class to which it belongs, select this class in the ODT | Classes branch of the ODT editor or in the Classes tree of the Classes editor. If you want to rename the desired property in the object it belongs to, select the object in the object hierarchy displayed in the ODT | Data branch of the ODT editor or in the Data tree of the Data editor.
  2. Right-click the chosen property and select Rename from context menu, or press F2. TestComplete will activate an in-place editor.
  3. Enter the desired name for the property.
  4. To apply changes, press Enter or click somewhere outside of the in-place editor. To cancel changes, press Esc.

To copy and paste a property

To copy a property to the clipboard:

  • Right-click the desired property in the editor and choose Copy from the context menu.

To paste a property from the clipboard:

  • In the editor select the parent class or object for the property, right-click on it and choose Paste from the context menu.
Note: To paste a property that stores an object instance from another project, you should declare the object’s class first. See How to Create, Rename and Delete Classes for instructions on this.

To change the property’s position

Objects created with ODT are organized in a tree-like structure. An object may contain a property referring to another object. That object may have a property referring to other objects and so on. When walking down the object tree, TestComplete analyzes the object properties, and if a property refers to another object, TestComplete executes methods of that object (see Controlling Object-Driven Tests). You may need to change the property’s position to change the object’s processing order.

To change the property’s position:

  • Right-click the desired property in the editor and choose Move Up or Move Down from the context menu to move the property in the corresponding direction.
Note: Besides properties, which an object “inherits” from a class, the object also can have properties that only belong to this object. These specific properties always reside after properties provided by the class. They also can be rearranged in the same way. However object-specific properties cannot be mixed with class properties. Class properties can be modified in the Classes editor or in the ODT | Classes branch of the ODT editor, while object-specific properties are modified via the Data editor or in the ODT | Data branch of the ODT editor.

To specify the property value

  1. If you want to specify the value for the desired property in the class to which it belongs, select this class in the ODT | Classes branch of the ODT editor or in the Classes tree of the Classes editor. If you want to specify the value for the desired property in the object it belongs to, select the object in the object hierarchy displayed in the ODT | Data branch of the ODT editor or in the Data tree of the Data editor.
  2. Right-click the chosen property and select Edit from context menu, or simply click the value field of the desired property.
  3. In the Value column, specify the property value. Properties can store an ordinary value (integer, string, date, etc.), an array or an object:
    • If the property is going to store an array or a reference to an object, select (Array) or the object name from the dropdown list of the Value column. To indicate that the property holds a reference to an object or an array, TestComplete displays the object's class name or the string Array in parenthesis, for example, (MyClass) or (Array). If you enclose that name in quotes, TestComplete will treat the property value as a string, for instance, "(MyClass)" or "(Array)".
    • To store a boolean value, type true or false. If you want to specify a string value holding the true or false string, enclose that string in quotes (that is, "true" or "false").
Note:

If you modify the value of a property in a class, the new value becomes the default property value. It can then be redefined in objects.

If you modify the value of a property in an object and you change this property so that it holds a reference to an object, TestComplete will create a new instance of this object. If you want a property to return a reference to an existing object, you should use a method instead of the property.

If a property stores an object that has not been created via the ODT or Data editor, for instance, one of TestComplete programming objects or any other OLE object (e.g. Word.Application), TestComplete displays (OleObject) as a property value. You can see this value in the ODT or Data editor during the test run.

If a class property holds an array and you add a new item to this array, the new item is inserted into the appropriate position in all "object" arrays (that is, arrays in objects that are based on this class). If you delete an item from a class array, it is deleted from all "object" arrays.

To delete a property

  1. If you want to delete the desired property from the class to which it belongs, select this class in the ODT | Classes branch of the ODT editor or in the Classes tree of the Classes editor. If you want to delete the desired property from the object it belongs to, select the object in the object hierarchy displayed in the ODT | Data branch of the ODT editor or in the Data tree of the Data editor.
  2. Right-click the chosen property and select Delete from the context menu.
  3. TestComplete will display a message box asking you if you want to delete the selected property. Press OK to delete the property, or Cancel to cancel the deletion.
Note: When you delete a property from a class, it is deleted from all objects that are based on the class.

See Also

Object-Driven Testing
ODT Editor
Classes Editor
How to Create, Modify and Delete Methods

Highlight search results