Name Property

Applies to TestComplete 15.69, last modified on November 13, 2024

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

The Class.Name property specifies the name of the ClassObj class. The class name is used to refer to this class in scripts, so the class name must match the naming rules of the project’s scripting language (it must be a valid identifier).

Declaration

ClassObj.Name

Read-Only Property String
ClassObj An expression, variable or parameter that specifies a reference to a Class object

Applies To

The property is applied to the following object:

Property Value

A string that holds the name of the ClassObj class.

Example

The code below posts the names of all the classes existing in the current project to the test log.

JavaScript, JScript

function ClassNameExample()
{
  var Classes = ODT.Classes;
  // Obtains the total number of the classes
  var ClassesNum = Classes.Count;

  // Iterates through the classes
  for (var i = 0; i < ClassesNum; i++)
  {
    var ClassName = Classes.Items(i).Name;
    // Posts a class name to the test log
    Log.Message("The " + (i+1) + " class is: " + ClassName);
  }
}

VBScript

Sub ClassNameExample()

  Set Classes = ODT.Classes
  ' Obtains the total number of the classes
  ClassesNum = Classes.Count

  ' Iterates through the classes
  For i = 0 to (ClassesNum - 1)
    ClassName = Classes.Items(i).Name
    ' Posts a class name to the test log
    Log.Message("The " & (i+1) & " class is: " & ClassName)
  Next
  
End Sub

DelphiScript

function ClassNameExample;
var Classes, ClassesNum, i, ClassName;
begin

  Classes := ODT.Classes;
  // Obtains the total number of the classes
  ClassesNum := Classes.Count;

  // Iterates through the classes
  For i := 0 to (ClassesNum - 1) do
  begin
    ClassName := Classes.Items[i].Name;
    // Posts a class name to the test log
    Log.Message('The ' + IntToStr(i+1) + ' class is: ' + ClassName);
  end;

end;

C++Script, C#Script

function ClassNameExample()
{
  var Classes = ODT["Classes"];
  // Obtains the total number of the classes
  var ClassesNum = Classes["Count"];

  // Iterates through the classes
  for (var i = 0; i < ClassesNum; i++)
  {
    var ClassName = Classes["Items"](i)["Name"];
    // Posts a class name to the test log
    Log["Message"]("The " + (i+1) + " class is: " + ClassName);
  }
}

See Also

Classes Object
Items Property

Highlight search results