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 variable
- Below the ODT | Data item in the ODT editor or below the Data item in the Data editor, right-click the data group to which a variable should be added.
- Select New Item from the context menu.
- TestComplete will create a new variable and name it NewVariable1. You can then rename the variable as you wish.
Since variables are held in data groups, you should create at least one group to be able to create a new variable.
Names of variables are used to refer to these variables 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 variable names are case-sensitive in JScript, C++Script and C#Script scripts, and case-insensitive in VBScript and DelphiScript scripts. |
To rename a variable
- In the ODT or Data editor, select the desired variable in the tree view.
- Right-click the chosen variable and select Rename from context menu, or press F2. TestComplete will activate an in-place editor.
- Enter the desired name for the variable.
- To apply changes, press Enter or click somewhere outside of the in-place editor. To cancel changes, press Esc.
To modify the variable value
- In the ODT or Data editor, select the desired variable in the tree view.
- Right-click the chosen variable and select Edit from context menu, or simply click the value field of the desired variable.
- In the Value column, specify the variable value. Variables can store an ordinary value (integer, string, date, etc.), an array or an object:
- To create an object, select the class name from the dropdown list of the Value column. TestComplete will automatically create a new object and display its properties as child nodes of the object's node. To indicate that the property holds a reference to an object, TestComplete displays the object's class name in parenthesis (for example, (MyClass)). If you enclose that name in quotes, TestComplete will treat the property value as a string (for instance, "(MyClass)").
- To create a new array, select (Array) from the dropdown list of the Value column. Then you can add items to the array by right-clicking the array node and selecting New Item from the context menu. If you need to specify a value holding the (Array) string, enclose that string in quotes (that is, "(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: | A variable can store an object. This can be an object created in the ODT or Data editor, one of TestComplete programming objects or any other OLE object you created in your test (for instance, it can be a Word.Application object). If a variable stores an OLE object that has not been created via the ODT or Data editor, TestComplete displays (OleObject) as a variable value. You can see this value in the ODT or Data editor during the test run. |
To copy and paste a variable
To copy a variable to the clipboard:
To paste a variable from the clipboard:
- In the editor select the parent group for the new variable, right-click on it and choose Paste from the context menu.
Note: | To paste a variable that stores an object 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 variable’s position
- Right-click the variable name in the editor and choose Move Up or Move Down from the context menu to move it in the corresponding direction.
To delete a variable
- Right-click the variable 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 variable. Click OK to delete the variable, or Cancel to cancel the deletion.