Enabled Property (Specific to Project Object)

Applies to TestComplete 12.60, last modified on September 17, 2018

Description

Use the TestItem.Enabled property to determine whether the given test item is executed when the project is run. This property holds True if the test item is checked in the Test Items page of the Project Editor, and False otherwise. Note that if the test item is disabled, neither it nor its child items are run, since a child test item can only be run if all of its parent items are enabled (that is, if the Enabled properties of all parent test items are True).

Declaration

Project TestItemObj.Enabled

Read-Only Property Boolean
Project TestItemObj An expression, variable or parameter that specifies a reference to a Project TestItem object

Applies To

The property is applied to the following object:

Property Value

True, if the test item is executed during the project run; False otherwise.

Example

The following example iterates through a project’s test items and posts their properties to the test log:

JavaScript

function Test()
{
  // Iterates through test items
  for (let i = 0; i < Project.TestItems.ItemCount; i++)
    LogTestItemInfo(Project.TestItems.TestItem(i));
}

function LogTestItemInfo(ATestItem)
{
  var TestItemInfo;
  // Obtains the test item name
  TestItemInfo = "Name: " + ATestItem.Name + "\r\n";

  // Obtains the test item description
  TestItemInfo = TestItemInfo + "Description: " + ATestItem.Description + "\r\n";

  // Obtains the name of the test run by the test item
  TestItemInfo = TestItemInfo + "Test: ";
  if (!strictEqual(ATestItem.ElementToBeRun, null))
    TestItemInfo = TestItemInfo + ATestItem.ElementToBeRun.Caption + "\r\n"
  else
    TestItemInfo = TestItemInfo + "not specified" + "\r\n";

  // Obtains the name of the parent item of the current test item
  TestItemInfo = TestItemInfo + "Parent: ";
  if (!strictEqual(ATestItem.Parent, null))
    TestItemInfo = TestItemInfo + ATestItem.Parent.Name + "\r\n"
  else
    TestItemInfo = TestItemInfo + "none" + "\r\n";

  // Determines whether the current test item is enabled
  TestItemInfo = TestItemInfo + "Enabled: " + ATestItem.Enabled + "\r\n";

  // Obtains the test item’s StopOnError property value
  TestItemInfo = TestItemInfo + "Stop on error: ";
  switch (ATestItem.StopOnError)
    {     case 0:
      TestItemInfo = TestItemInfo + "None" + "\r\n";
      break;
    case 1:
      TestItemInfo = TestItemInfo + "Project" + "\r\n";
      break;
    case 2:
      TestItemInfo = TestItemInfo + "Test Item" + "\r\n";
      break;
    }

  // Obtains the test item’s StopOnException property value
  TestItemInfo = TestItemInfo + "Stop on exception: ";
  switch (ATestItem.StopOnException)
    {
    case 0:
      TestItemInfo = TestItemInfo + "None" + "\r\n";
      break;
    case 1:
      TestItemInfo = TestItemInfo + "Project" + "\r\n";
      break;
    case 2:
      TestItemInfo = TestItemInfo + "Test Item" + "\r\n";
      break;
    }

  // Obtains the amount of time the test item is executed
  TestItemInfo = TestItemInfo + "Count: " + ATestItem.Count + "\r\n";

  // Obtains the test item’s timeout
  TestItemInfo = TestItemInfo + "Timeout: " + ATestItem.Timeout + "\r\n";

  // Checks if the test item is currently running
  TestItemInfo = TestItemInfo + "Is currently running: ";
  if (ATestItem.Iteration > 0)
    TestItemInfo = TestItemInfo + "yes"
  else
    TestItemInfo = TestItemInfo + "no";

  // Posts test item information to the test log
  Log.AppendFolder(ATestItem.Name, TestItemInfo);

  // Iterates through the child items of the current test item
  for (let i = 0; i < ATestItem.ItemCount; i++)

    // Posts information on the current test item’s child items to the test log
    LogTestItemInfo(ATestItem.TestItem(i));
  Log.PopLogFolder();
}

JScript

function Test()
{
  var i;
  // Iterates through test items
  for (i = 0; i < Project.TestItems.ItemCount; i++)
    LogTestItemInfo(Project.TestItems.TestItem(i));
}

function LogTestItemInfo(ATestItem)
{
  var TestItemInfo, i;
  // Obtains the test item name
  TestItemInfo = "Name: " + ATestItem.Name + "\r\n";

  // Obtains the test item description
  TestItemInfo = TestItemInfo + "Description: " + ATestItem.Description + "\r\n";

  // Obtains the name of the test run by the test item
  TestItemInfo = TestItemInfo + "Test: ";
  if (ATestItem.ElementToBeRun != null)
    TestItemInfo = TestItemInfo + ATestItem.ElementToBeRun.Caption + "\r\n"
  else
    TestItemInfo = TestItemInfo + "not specified" + "\r\n";

  // Obtains the name of the parent item of the current test item
  TestItemInfo = TestItemInfo + "Parent: ";
  if (ATestItem.Parent != null)
    TestItemInfo = TestItemInfo + ATestItem.Parent.Name + "\r\n"
  else
    TestItemInfo = TestItemInfo + "none" + "\r\n";

  // Determines whether the current test item is enabled
  TestItemInfo = TestItemInfo + "Enabled: " + ATestItem.Enabled + "\r\n";

  // Obtains the test item’s StopOnError property value
  TestItemInfo = TestItemInfo + "Stop on error: ";
  switch (ATestItem.StopOnError)
    {     case 0:
      TestItemInfo = TestItemInfo + "None" + "\r\n";
      break;
    case 1:
      TestItemInfo = TestItemInfo + "Project" + "\r\n";
      break;
    case 2:
      TestItemInfo = TestItemInfo + "Test Item" + "\r\n";
      break;
    }

  // Obtains the test item’s StopOnException property value
  TestItemInfo = TestItemInfo + "Stop on exception: ";
  switch (ATestItem.StopOnException)
    {
    case 0:
      TestItemInfo = TestItemInfo + "None" + "\r\n";
      break;
    case 1:
      TestItemInfo = TestItemInfo + "Project" + "\r\n";
      break;
    case 2:
      TestItemInfo = TestItemInfo + "Test Item" + "\r\n";
      break;
    }

  // Obtains the amount of time the test item is executed
  TestItemInfo = TestItemInfo + "Count: " + ATestItem.Count + "\r\n";

  // Obtains the test item’s timeout
  TestItemInfo = TestItemInfo + "Timeout: " + ATestItem.Timeout + "\r\n";

  // Checks if the test item is currently running
  TestItemInfo = TestItemInfo + "Is currently running: ";
  if (ATestItem.Iteration > 0)
    TestItemInfo = TestItemInfo + "yes"
  else
    TestItemInfo = TestItemInfo + "no";

  // Posts test item information to the test log
  Log.AppendFolder(ATestItem.Name, TestItemInfo);

  // Iterates through the child items of the current test item
  for (i = 0; i < ATestItem.ItemCount; i++)

    // Posts information on the current test item’s child items to the test log
    LogTestItemInfo(ATestItem.TestItem(i));
  Log.PopLogFolder();
}

Python

def Test():
  # Iterates through test items
  for i in range(0, Project.TestItems.ItemCount):
    LogTestItemInfo(Project.TestItems.TestItem[i])

def LogTestItemInfo(ATestItem):
  # Obtains the test item name 
  TestItemInfo = "Name: " + str(ATestItem.Name) + "\r\n"
  # Obtains the test item description 
  TestItemInfo = TestItemInfo + "Description: " + str(ATestItem.Description) + "\r\n"
  # Obtains the name of the test run by the test item 
  TestItemInfo = TestItemInfo + "Test: "
  if ATestItem.ElementToBeRun != None:
    TestItemInfo = TestItemInfo + ATestItem.ElementToBeRun.Caption + "\r\n"
  else:
    TestItemInfo = TestItemInfo + "not specified" + "\r\n"
  # Obtains the name of the parent item of the current test item 
  TestItemInfo = TestItemInfo + "Parent: "
  if ATestItem.Parent != None:
    TestItemInfo = TestItemInfo + str(ATestItem.Parent.Name) + "\r\n"
  else:
    TestItemInfo = TestItemInfo + "none" + "\r\n"
  # Determines whether the current test item is enabled 
  TestItemInfo = TestItemInfo + "Enabled: " + str(ATestItem.Enabled) + "\r\n"
  # Obtains the test item's StopOnError property value 
  TestItemInfo = TestItemInfo + "Stop on error: "
  if ATestItem.StopOnError == 0:
    TestItemInfo = TestItemInfo + "None" + "\r\n"
  elif ATestItem.StopOnError == 1:
    TestItemInfo = TestItemInfo + "Project" + "\r\n"
  elif ATestItem.StopOnError == 2:
    TestItemInfo = TestItemInfo + "Test Item" + "\r\n"
  # Obtains the test item's StopOnException property value 
  TestItemInfo = TestItemInfo + "Stop on exception: "
  if ATestItem.StopOnException == 0:
    TestItemInfo = TestItemInfo + "None" + "\r\n"
  elif ATestItem.StopOnException == 1:
    TestItemInfo = TestItemInfo + "Project" + "\r\n"
  elif ATestItem.StopOnException == 2:
    TestItemInfo = TestItemInfo + "Test Item" + "\r\n"
  # Obtains the amount of time the test item is executed 
  TestItemInfo = TestItemInfo + "Count: " + str(ATestItem.Count) + "\r\n"
  # Obtains the test item's timeout
  TestItemInfo = TestItemInfo + "Timeout: " + str(ATestItem.Timeout) + "\r\n"
  # Checks if the test item is currently running 
  TestItemInfo = TestItemInfo + "Is currently running: "
  if ATestItem.Iteration > 0:
    TestItemInfo = TestItemInfo + "yes"
  else:
    TestItemInfo = TestItemInfo + "no"
  # Posts test item information to the test log
  Log.AppendFolder(ATestItem.Name, TestItemInfo)
  # Iterates through the child items of the current test item
  for i in range(0, ATestItem.ItemCount):
    # Posts information on the current test item's child items to the test log 
    LogTestItemInfo(ATestItem.TestItem[i])
  Log.PopLogFolder()

VBScript

Sub Test
  Dim i
  ' Iterates through test items
  For i = 0 To Project.TestItems.ItemCount - 1
    LogTestItemInfo(Project.TestItems.TestItem(i))
  Next
End Sub

Sub LogTestItemInfo(ATestItem)
  Dim TestItemInfo, i
  ' Obtains the test item name
  TestItemInfo = "Name: " & ATestItem.Name & vbCrLf

  ' Obtains the test item description
  TestItemInfo = TestItemInfo & "Description: " & ATestItem.Description & vbCrLf

  ' Obtains the name of the test run by the test item
  TestItemInfo = TestItemInfo & "Test: "
  If Not ATestItem.ElementToBeRun Is Nothing Then
    TestItemInfo = TestItemInfo & ATestItem.ElementToBeRun.Caption & vbCrLf
  Else
    TestItemInfo = TestItemInfo & "not specified" & vbCrLf
  End If

  ' Obtains the name of the parent item of the current test item
  TestItemInfo = TestItemInfo & "Parent: "
  If Not ATestItem.Parent Is Nothing Then
    TestItemInfo = TestItemInfo & ATestItem.Parent.Name & vbCrLf
  Else
    TestItemInfo = TestItemInfo & "none" & vbCrLf
  End If

  ' Determines whether the current test item is enabled
  TestItemInfo = TestItemInfo & "Enabled: " & ATestItem.Enabled & vbCrLf

  ' Obtains the test item’s StopOnError property value
  TestItemInfo = TestItemInfo & "Stop on error: "
  Select Case ATestItem.StopOnError
    Case 0 TestItemInfo = TestItemInfo & "None" & vbCrLf
    Case 1 TestItemInfo = TestItemInfo & "Project" & vbCrLf
    Case 2 TestItemInfo = TestItemInfo & "Test Item" & vbCrLf
  End Select

  ' Obtains the test item’s StopOnException property value
  TestItemInfo = TestItemInfo & "Stop on exception: "
  Select Case ATestItem.StopOnException
    Case 0 TestItemInfo = TestItemInfo & "None" & vbCrLf
    Case 1 TestItemInfo = TestItemInfo & "Project" & vbCrLf
    Case 2 TestItemInfo = TestItemInfo & "Test Item" & vbCrLf
  End Select

  ' Obtains the amount of time the test item is executed
  TestItemInfo = TestItemInfo & "Count: " & ATestItem.Count & vbCrLf

  ' Obtains the test item’s timeout
  TestItemInfo = TestItemInfo & "Timeout: " & ATestItem.Timeout & vbCrLf

  ' Checks if the test item is currently running
  TestItemInfo = TestItemInfo & "Is currently running: "
  If ATestItem.Iteration > 0 Then
    TestItemInfo = TestItemInfo & "yes"
  Else
    TestItemInfo = TestItemInfo & "no"
  End If

  ' Posts test item information to the test log
  Call Log.AppendFolder(ATestItem.Name, TestItemInfo)

  ' Iterates through the child items of the current test item
  For i = 0 To ATestItem.ItemCount-1

    ' Posts information on the current test item’s child items to the test log
    LogTestItemInfo(ATestItem.TestItem(i))
  Next
  Log.PopLogFolder
End Sub

DelphiScript

procedure LogTestItemInfo(ATestItem);
var TestItemInfo, i;
begin
  // Obtains the test item name
  TestItemInfo := 'Name: ' + ATestItem.Name + #13#10;

  // Obtains the test item description
  TestItemInfo := TestItemInfo + 'Description: ' + ATestItem.Description + #13#10;

  // Obtains the name of the test run by the test item
  TestItemInfo := TestItemInfo + 'Test: ';
  if ATestItem.ElementToBeRun <> nil then
    TestItemInfo := TestItemInfo + ATestItem.ElementToBeRun.Caption + #13#10
  else
    TestItemInfo := TestItemInfo + 'not specified' + #13#10;

  // Obtains the name of the parent item of the current test item
  TestItemInfo := TestItemInfo + 'Parent: ';
  if ATestItem.Parent <> nil then
    TestItemInfo := TestItemInfo + ATestItem.Parent.Name + #13#10
  else
    TestItemInfo := TestItemInfo + 'none' + #13#10;

  // Determines whether the current test item is enabled
  TestItemInfo := TestItemInfo + 'Enabled: ' + aqConvert.VarToStr(ATestItem.Enabled) + #13#10;

  // Obtains the test item’s StopOnError property value
  TestItemInfo := TestItemInfo + 'Stop on error: ';
  case ATestItem.StopOnError of
    0: TestItemInfo := TestItemInfo + 'None' + #13#10;
    1: TestItemInfo := TestItemInfo + 'Project' + #13#10;
    2: TestItemInfo := TestItemInfo + 'Test Item' + #13#10;
    end;

  // Obtains the test item’s StopOnException property value
  TestItemInfo := TestItemInfo + 'Stop on exception: ';
  case ATestItem.StopOnException of
    0: TestItemInfo := TestItemInfo + 'None' + #13#10;
    1: TestItemInfo := TestItemInfo + 'Project' + #13#10;
    2: TestItemInfo := TestItemInfo + 'Test Item' + #13#10;
    end;

  // Obtains the amount of time the test item is executed
  TestItemInfo := TestItemInfo + 'Count: ' + aqConvert.VarToStr(ATestItem.Count) + #13#10;

  // Obtains the test item’s timeout
  TestItemInfo := TestItemInfo + 'Timeout: ' + aqConvert.VarToStr(ATestItem.Timeout) + #13#10;

  // Checks if the test item is currently running
  TestItemInfo := TestItemInfo + 'Is currently running: ';
  if ATestItem.Iteration > 0 then
    TestItemInfo := TestItemInfo + 'yes'
  else
    TestItemInfo := TestItemInfo + 'no';

  // Posts test item information to the test log
  Log.AppendFolder(ATestItem.Name, TestItemInfo);

  // Iterates through the child items of the current test item
  for i := 0 to ATestItem.ItemCount - 1 do

    // Posts information on the current test item’s child items to the test log
    LogTestItemInfo(ATestItem.TestItem(i));
  Log.PopLogFolder;
end;

procedure Test();
var i;
begin
  // Iterates through test items
  for i := 0 to Project.TestItems.ItemCount - 1 do
    LogTestItemInfo(Project.TestItems.TestItem(i));
end;

C++Script, C#Script

function Test()
{
  var i;
  // Iterates through test items
  for (i = 0; i < Project["TestItems"]["ItemCount"]; i++)
    LogTestItemInfo(Project["TestItems"]["TestItem"](i));
}

function LogTestItemInfo(ATestItem)
{
  var TestItemInfo, i;
  // Obtains the test item name
  TestItemInfo = "Name: " + ATestItem["Name"] + "\r\n";

  // Obtains the test item description
  TestItemInfo = TestItemInfo + "Description: " + ATestItem["Description"] + "\r\n";

  // Obtains the name of the test run by the test item
  TestItemInfo = TestItemInfo + "Test: ";
  if (ATestItem["ElementToBeRun"] != null)
    TestItemInfo = TestItemInfo + ATestItem["ElementToBeRun"]["Caption"] + "\r\n"
  else
    TestItemInfo = TestItemInfo + "not specified" + "\r\n";

  // Obtains the name of the parent item of the current test item
  TestItemInfo = TestItemInfo + "Parent: ";
  if (ATestItem["Parent"] != null)
    TestItemInfo = TestItemInfo + ATestItem["Parent"]["Name"] + "\r\n"
  else
    TestItemInfo = TestItemInfo + "none" + "\r\n";

  // Determines whether the current test item is enabled
  TestItemInfo = TestItemInfo + "Enabled: " + ATestItem["Enabled"] + "\r\n";

  // Obtains the test item’s StopOnError property value
  TestItemInfo = TestItemInfo + "Stop on error: ";
  switch (ATestItem["StopOnError"])
    {     case 0:
      TestItemInfo = TestItemInfo + "None" + "\r\n";
      break;
    case 1:
      TestItemInfo = TestItemInfo + "Project" + "\r\n";
      break;
    case 2:
      TestItemInfo = TestItemInfo + "Test Item" + "\r\n";
      break;
    }

  // Obtains the test item’s StopOnException property value
  TestItemInfo = TestItemInfo + "Stop on exception: ";
  switch (ATestItem["StopOnException"])
    {
    case 0:
      TestItemInfo = TestItemInfo + "None" + "\r\n";
      break;
    case 1:
      TestItemInfo = TestItemInfo + "Project" + "\r\n";
      break;
    case 2:
      TestItemInfo = TestItemInfo + "Test Item" + "\r\n";
      break;
    }

  // Obtains the amount of time the test item is executed
  TestItemInfo = TestItemInfo + "Count: " + ATestItem["Count"] + "\r\n";

  // Obtains the test item’s timeout
  TestItemInfo = TestItemInfo + "Timeout: " + ATestItem["Timeout"] + "\r\n";

  // Checks if the test item is currently running
  TestItemInfo = TestItemInfo + "Is currently running: ";
  if (ATestItem["Iteration"] > 0)
    TestItemInfo = TestItemInfo + "yes"
  else
    TestItemInfo = TestItemInfo + "no";

  // Posts test item information to the test log
  Log.AppendFolder(ATestItem["Name"], TestItemInfo);

  // Iterates through the child items of the current test item
  for (i = 0; i < ATestItem["ItemCount"]; i++)

    // Posts information on the current test item’s child items to the test log
    LogTestItemInfo(ATestItem["TestItem"](i));
  Log["PopLogFolder"]();
}

See Also

ElementToBeRun Property
StopOnError Property
Timeout Property
Tests and Test Items

Highlight search results