Log.SaveResultsAs Method

Applies to TestComplete 14.10, last modified on June 5, 2019

Description

The Log.SaveResultsAs method exports the current test log to the HTML, XML, or MHT format. 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.

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.

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