Forum Discussion

Elise_LeBlanc's avatar
Elise_LeBlanc
New Contributor
14 years ago

Can I change the location of the .mht file produced from Test Execute?

I would like to be able to specify a location for the tcResults.mht file created after a Test Execute run.  Currently, I find it in c:\users\myuser\appdata\local\temp.



I have looked  in the Options dialog but have not found a place to change the location.



Any help would be appreciated - Elise

6 Replies


  • Hi Elise,





    In TestComplete, you can implement an event handler for the OnStopTest event to export your test log to the needed location after the test execution is completed. For example:





    function GeneralEvents_OnStopTest(Sender)

    {

      Log.SaveResultsAs("c:\\MyFolder\\myLog.mht", 2);

    }






    Please see the Log.SaveResultsAs and 'Handling Events' TestComplete help topics for more information. Also, please note that you will need to disable the 'Activate after test run' option described in the 'Log Options Dialog' help topic in TestExecute.
  • Hi,



    I am using the following code, actually trying to bind the current date and time with Log File and saving it on a network location, but it does not save the log. Any idea what would be the problem with that code.



    Sub GeneralEvents_OnStopTest(Sender)

        FolderPath = "P:\\QA Activity\\01. AUTOMATION\\08 - Test Scripts\\Test Result\\"

        strDate = aqConvert.DateTimeToStr(Date)

        strDate = aqString.Replace(strDate,"/","-")

        LogName = FolderPath&"("&Sys.UserName&")-CDB-"&strDate&"-"&Time&".mht"

        Log.SaveResultsAs LogName,2

    End Sub



    Thanks in advance.

    Regards,

  • Hi Muhammad,





    You need to make two corrections to your script.

    1. Replace all double slashes with single ones in FolderPath:



      FolderPath = "P:\QA Activity\01. AUTOMATION\08 - Test Scripts\Test Result\"







    2. Remove colons in the result returned by Time, as filenames cannot contain them. To do this, modify the line starting with 'LogName' in the following way:



      LogName = FolderPath&"("&Sys.UserName&")-CDB-"&strDate&"-"&aqString.Replace(Time,":","")&".mht"

  • mgaert's avatar
    mgaert
    New Contributor
    Hallo @all,



    Is it posible use the Log.SaveResultsAs to save it on a server path?

    JScript:

    function GeneralEvents_OnStopTest(Sender)

    {

      Log.SaveResultsAs("\\server\path_on_server\myLog.mht", 2);

    }



    Thanks for Help!

    Michael


  • Hi Michael,





    Yes, but it is necessary to double slashes in the path, as you are using JScript:







    function GeneralEvents_OnStopTest(Sender) 



      Log.SaveResultsAs("\\\\server\\path_on_server\\myLog.mht", 2); 

    }