Log.SaveResultsAs Method

Applies to TestComplete 14.20, last modified on September 11, 2019

Description

The Log.SaveResultsAs method exports the current test log to the HTML, XML, MHT or JUnit-style format. Also, this method allows you to pack the full test log or the exported HTML files into a ZIP archive. The exported log contains all entries posted until the SaveResultsAs call. If the test is run as part of a project or project suite run, you can choose whether to export the project suite, project, or test item log.

If you call the SaveResultsAs method during the test run, you will get an incomplete result.

You can also export test logs manually, as explained in Exporting Test Results.

Declaration

Log.SaveResultsAs(FileNameLogFormatExportVisualizerImagesLogScope)

FileName [in]    Required    String    
LogFormat [in]    Optional    Integer Default value: 0 (XML format)   
ExportVisualizerImages [in]    Optional    Boolean Default value: True   
LogScope [in]    Optional    Integer Default value: 0 (full test log)   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

FileName

The file path (when exporting to XML or MHT) or folder path (when exporting to XML or HTML) to save the log to. If the parent folders do not exist, they will be created.

Note: For XML exporting, you can specify either a fully-qualified path to the file that will contain test results or a folder path. If you specify the folder path only, TestComplete will save test results to the Description.tcLog file in this folder.

The destination folder must be different from the location of the current run's log (Log.Path) or any of its subfolders.

LogFormat

The format of the exported log:

Constant Value Description
lsXML 0 XML format (default).

When you use the XML format for log data, then —

  • The LogScope parameter is ignored.

  • The FileName parameter can specify the file name for export or just a folder. See the note above.

lsHTML 1 HTML format – a web page with accompanying images, stylesheets and other data files. The FileName parameter specifies the folder to save the files. The web page name is index.htm.
lsMHT 2 MHT file – a web page archive (web page with accompanying files packed into one file). MHT files that can be viewed in Internet Explorer, but not Chrome or Firefox.
lsZip 3 ZIP format – a zip archive with files containing a full generated test log.
lsPackedHTML 4 Packed HTML format – a zip archive included an exported test log in HTML format.
lsJUnit 5 JUnit format – an XML file with a Summary report saved in the JUnit report format. You can view and process the report in any JUnit-style-compatible framework or in a tool like JUnit Viewer, xUnit Viewer, or Allure.

ExportVisualizerImages

Specifies whether to export Visualizer images. Default is True. Use False to reduce the size of the exported log.

LogScope

The scope of the log to be exported in case the test is run as part of a project or project suite run. Possible values:

Constant Value Description
lesFull 0 (Default) Export the project suite log.
lesCurrentProject 1 Export the project log.
lesCurrentTestItem 2 Export the log of the current test item.
Note: When exporting to XML, this parameter is ignored and always set to lesFull.

Result Value

True if the test log is exported successfully and False otherwise.

Remarks

  • Images are exported in the format specified by the Image format project option.

  • In HTML and MHT logs, links posted by Log.Link are handled as follows:

    • Web and FTP links (starting with http://, https://, www or ftp://) are included. Links without the protocol (for example, mysite.com) are not included.
    • File links (C:\MyFile.txt, \\server\folder\file.txt) are included, and these files are copied to the exported log.
    • Other links (for example, mailto:) are not included in exported logs – the Link column will be empty.

Example

Export to MHT (Single File)

JavaScript, JScript

function Test()
{
  // Do something
  // ...

  Log.SaveResultsAs("C:\\Work\\Log.mht", lsMHT);
}

Python

def Test():
  # Do something
  # ...
  Log.SaveResultsAs("C:\\Work\\Log.mht", lsMHT)

VBScript

Sub Test
  ' Do something
  ' ...

  Call Log.SaveResultsAs("C:\Work\Log.mht", lsMHT)
End Sub

DelphiScript

procedure Test;
begin
  // Do something
  // ...

  Log.SaveResultsAs('C:\Work\Log.mht', lsMHT);
end;

C++Script, C#Script

function Test()
{
  // Do something
  // ...

  Log["SaveResultsAs"]("C:\\Work\\Log.mht", lsMHT);
}

Export to HTML

JavaScript, JScript

function Test()
{
  // Do something
  // ...

  Log.SaveResultsAs("C:\\Work\\Log\\", lsHTML); // Files are created in the Log folder
}

Python

def Test1():
  # Do something
  # ...
  Log.SaveResultsAs("C:\\Work\\Log\\", lsHTML) # Files are created in the Log folder

VBScript

Sub Test
  ' Do something
  ' ...

  Call Log.SaveResultsAs("C:\Work\Log\", lsHTML) ' Files are created in the Log folder
End Sub

DelphiScript

procedure Test;
begin
  // Do something
  // ...

  Log.SaveResultsAs('C:\Work\Log\', lsHTML); // Files are created in the Log folder
end;

C++Script, C#Script

function Test()
{
  // Do something
  // ...

  Log["SaveResultsAs"]("C:\\Work\\Log\\", lsHTML); // Files are created in the Log folder
}

See Also

Exporting Test Results
Exported Results Structure
Test Results
Integration.Integration.ExportResults
Log.Path Property

Highlight search results