Caption Property

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The TestItemElement.Caption property lets you get the caption of the entity that is executed by the test item. This is the same value that you see in the Execution entity column on the Execution Plan editor in the project.

Declaration

TestItemElementObj.Caption

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

Applies To

The property is applied to the following object:

Property Value

A string holding the entity caption.

Example

The following example obtains the name of the currently executed test and posts this name to the test log:

JavaScript, JScript

function Test()
{
  var Tests, TestItem, Test;
  // Obtains the project’s test items
  Tests = Project.TestItems;
  // Obtains the test item which is currently running
  TestItem = Tests.Current;
  // Obtains the test executed by the test item
  Test = TestItem.ElementToBeRun;
  // Posts the name of the executed test to the log
  Log.Message("The " + Test.Caption + " test is being executed.");
}

Python

def Test():
  # Obtains the project's test items
  Tests = Project.TestItems
  # Obtains the test item which is currently running
  TestItem = Tests.Current
  # Obtains the test executed by the test item
  Test = TestItem.ElementToBeRun
  # Posts the name of the executed test to the log
  Log.Message("The " + Test.Caption + " test is being executed.")

VBScript

Sub Test
  Dim Tests, TestItem, Test
  ' Obtains the project’s test items
  Set Tests = Project.TestItems
  ' Obtains the test item which is currently running
  Set TestItem = Tests.Current
  ' Obtains the test executed by the test item
  Set Test = TestItem.ElementToBeRun
  ' Posts the name of the executed test to the log
  Log.Message("The " & Test.Caption & " test is being executed.")
End Sub

DelphiScript

procedure Test();
var Tests, TestItem, Test;
begin
  // Obtains the project’s test items
  Tests := Project.TestItems;
  // Obtains the test item which is currently running
  TestItem := Tests.Current;
  // Obtains the test executed by the test item
  Test := TestItem.ElementToBeRun;
  // Posts the name of the executed test to the log
  Log.Message('The ' + Test.Caption + ' test is being executed.');
end;

C++Script, C#Script

function Test()
{
  var Tests, TestItem, Test;
  // Obtains the project’s test items
  Tests = Project["TestItems"];
  // Obtains the test item which is currently running
  TestItem = Tests["Current"];
  // Obtains the test executed by the test item
  Test = TestItem["ElementToBeRun"];
  // Posts the name of the executed test to the log
  Log["Message"]("The " + Test["Caption"] + " test is being executed.");
}

See Also

Execution Plan Editor
ElementToBeRun Property

Highlight search results