Project.Logs Property

Applies to TestComplete 15.63, last modified on April 22, 2024

Description

This property returns the LogResults object that provides a scripting interface to the test logs of a current project. The project logs are displayed under the Project_Suite_Name Logs | Project_Name Logs node in the Project Explorer panel and hold results of test runs for a project, its test items, project items or their elements (for example, single script routines, low-level procedures, and so on).

Via the Project.Logs property, you can operate with test results directly from scripts. This feature helps you process test results in a specific manner, for instance, you can export them to a custom file format that is different from the one offered by TestComplete. For more information on working with log contents from scripts, see Scripting Access to the Test Log Contents.

Declaration

Project.Logs

Read-Only Property A LogResults object

Applies To

The property is applied to the following object:

Property Value

A LogResults object that represents the collection of the project’s logs.

Example

The following example demonstrates how to obtain the list of the current project’s test logs.

JavaScript, JScript

function ProjectSample()
{
  var Logs, Count, Name, Status;
  // Obtains the object that holds the list of project logs
  Logs = Project.Logs;

  Count = Logs.LogItemsCount
  // Iterates through the list of project logs
  for (var i = 0; i < Count; i++)
  {
    Name = Logs.LogItem(i).Name;
    Status = Logs.LogItem(i).Status;
    switch(Status)
    {
      case 0:
        Log.Message(Name);
        break;
      case 1:
        Log.Warning(Name);
        break;
      case 2:
        Log.Error(Name);
        break;
    }
  }

}

Python

def ProjectSample():
  # Obtains the object that holds the list of project logs
  Logs = Project.Logs
  Count = Logs.LogItemsCount
  # Iterates through the list of project logs
  for i in range(0, Count):
    Name = Logs.LogItem[i].Name;
    Status = Logs.LogItem[i].Status;
    if Status == 0:
      Log.Message(Name)
    elif Status == 1:
      Log.Warning(Name)
    elif Status == 2:
      Log.Error(Name)

VBScript

Sub ProjectSample

  Dim Logs
  ' Obtains the object that holds the list of project logs
  Set Logs = Project.Logs

  Count = Logs.LogItemsCount
  ' Iterates through the list of project logs
  For i = 0 To Count - 1
    Name = Logs.LogItem(i).Name
    Status = Logs.LogItem(i).Status
    Select Case Status
      Case 0 Log.Message Name
      Case 1 Log.Warning Name
      Case 2 Log.Error Name
    End Select
  Next

End Sub

DelphiScript

procedure ProjectSample();
var Logs, Count, Name, Status, i;
begin
  // Obtains the object that holds the list of project logs
  Logs := Project.Logs;

  Count := Logs.LogItemsCount;
  // Iterates through the list of project logs
  for i := 0 to Count - 1 do
  begin
    Name := Logs.LogItem(i).Name;
    Status := Logs.LogItem(i).Status;
    case Status of
      0: Log.Message(Name);
      1: Log.Warning(Name);
      2: Log.Error(Name);
    end;
  end;

end;

C++Script, C#Script

function ProjectSample()
{
  var Logs, Count, Name, Status;
  // Obtains the object that holds the list of project logs
  Logs = Project["Logs"];

  Count = Logs["LogItemsCount"];
  // Iterates through the list of project logs
  for (var i = 0; i < Count; i++)
  {
    Name = Logs["LogItem"](i)["Name"];
    Status = Logs["LogItem"](i)["Status"];
    switch(Status)
    {
      case 0:
        Log["Message"](Name);
        break;
      case 1:
        Log["Warning"](Name);
        break;
      case 2:
        Log["Error"](Name);
        break;
    }
  }

}

See Also

Access Test Log Contents from Tests
LogResults Object

Highlight search results