TestItemElement Object

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The TestItemElement object provides a scripting interface to the entity executed by a project’s test item. It is specified in the Execution entity column in the Execution Plan editor of the project.

To obtain a TestItemElement object, use the TestItem.ElementToBeRun property.

Members

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

Tests, Test Items, and Test Cases
Execution Plan Editor
ElementToBeRun Property

Highlight search results