Exporting log to MHT format

If you need to make a report, generated by TestComplete, to somebody who has no TestComplete pre-installed, it would be more convenient to generate it in a format which can be portably opened on any computer.

TestComplete allows saving reports in the MHT format (archived HTML), which can be opened in any version of Internet Explorer browser.

How to do it...

In order to generate an MHT file we need to perform the following steps:

  1. Create and launch the following function:
    function testExportResults()
    {
      Log.Message("Message 1");
      Log.Error("Error 1");
      Log.SaveResultsAs("c:\results.mht", lsMHT);
    }

    In the result, we get the log in TestComplete window and the file c: esults.mht with similar contents.

  2. Open the following file c: esults.mht (by double-clicking on its name in the Explorer window) and make sure it can be opened in the browser (Internet Explorer, by default).

How it works...

The method of Log.SaveResultsAs stores the log into the file of the MHT format, regardless of the number of scripts launched; therefore this method should be evoked just once at the end of working of all the scripts.

As the first parameter, the full name of the file has to be signified, the second parameter assigns the following format: lsMHT, lsHTML, or lsXML. The most convenient format is that of MHT, as a result, just one file will be generated, which is viewable on any computer.

If there arises an error during the export, the Log.SaveResultsAs method returns false.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.181