Clear Method

Applies to TestComplete 15.45, last modified on December 01, 2022

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 Classes.Clear method to delete all existing classes from the collection of classes created via the ODT project item.

Declaration

ClassesObj.Clear()

ClassesObj An expression, variable or parameter that specifies a reference to a Classes object
Result None

Applies To

The method is applied to the following object:

Result Value

None.

Remarks

If the ODT.Data object holds any class instances (object variables), an error will occur. To delete a class instance from a data group, use the Group.DeleteVariable method. To delete all data from the Data object, call ODT.Data.Clear.

Example

The code below creates two new classes and then clears data and class collections at the end of the test run.

JavaScript, JScript

function ClearClassesExample()
{
  // Declares new classes
  ODT.Classes.Declare("MyClass");
  ODT.Classes.Declare("NewClass");
  // ...
  
  // Deletes all data from the Data object
  ODT.Data.Clear();
  
  // Deletes all the classes from the project
  ODT.Classes.Clear();
}

VBScript

Sub ClearClassesExample()

  ' Declares new classes
  ODT.Classes.Declare("MyClass")
  ODT.Classes.Declare("NewClass")
  ' ...
  
  ' Deletes all data from the Data object
  ODT.Data.Clear()
  
  ' Deletes all the classes from the project
  ODT.Classes.Clear()

End Sub

DelphiScript

function ClearClassesExample;
begin

  // Declares new classes
  ODT.Classes.Declare('MyClass');
  ODT.Classes.Declare('NewClass');
  // ...
  
  // Deletes all data from the Data object
  ODT.Data.Clear();
  
  // Deletes all the classes from the project
  ODT.Classes.Clear();

end;

C++Script, C#Script

function ClearClassesExample()
{
  // Declares new classes
  ODT["Classes"]["Declare"]("MyClass");
  ODT["Classes"]["Declare"]("NewClass");
  // ...
  
  // Deletes all data from the Data object
  ODT["Data"]["Clear"]();
  
  // Deletes all the classes from the project
  ODT["Classes"]["Clear"]();
}

See Also

Declare Method

Highlight search results