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.
To create a new class
- Right-click the ODT | Classes item in the ODT editor or the Classes item in the Classes editor.
- Select New Item from the context menu.
- TestComplete will create a new class and give it a simple name, e.g. NewClass1. You can then rename the class as you wish.
|Names of classes are used for referring to classes 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 class names are case-sensitive in JScript, C++Script and C#Script scripts, and case-insensitive in VBScript and DelphiScript scripts.|
|Note:||The name OleObject is reserved. You cannot create classes with this name.|
Creation of a new class is an analogue of declaring a class in programming. It does not create an instance of this class. To create a class instance, you need to create a new object.
To rename a class
- In the ODT or Classes editor, right-click the class that you want to rename and select Rename from the context menu, or choose the desired class in the tree view and press F2. TestComplete will activate an in-place editor.
- Enter the desired name for the class.
- To apply changes, press Enter or click somewhere outside of the in-place editor. To cancel changes, press Esc.
To copy and paste a class
You can copy and paste class declarations within a project or between different projects. The names and values of class properties and methods are preserved.
To copy a class declaration to the clipboard:
- Right-click the desired class name in the ODT or Classes editor and choose Copy from the context menu.
To paste a class declaration from the clipboard:
- Select the position in the editor, where you want the new class to be located. A class can only be pasted to the same hierarchy level from which it was copied.
- Click the right mouse button and select Paste from the context menu.
|Note:||When copying a class from one project to another, the names of script routines for class methods are copied without any changes. Thus, it is very likely that a new project would not contain the routines with the specified names. Therefore, you should redefine method handling routines in order to utilize the new class.|
To change the class position
By default the classes names are shown in the same order that they were created in. However, you can rearrange them in whatever order you like. To do this:
- Right-click the desired class name in the editor and choose Move Up or Move Down from the context menu to move the class in the corresponding direction.
To delete a class
- In the ODT or Classes editor, right-click the class you want to delete and select Delete from the context menu.
- TestComplete will display a message box asking you if you want to delete the selected class. Click OK to delete the class, or Cancel to cancel the deletion.
|Note:||When you delete a class, all objects that are based on this class are also deleted.|