Forum Discussion

GAutomation's avatar
GAutomation
Frequent Contributor
6 years ago
Solved

Log.saveresult

log.saveresultAs(filename,lshtml) generates a html file each time when we run the script. I want to rename that html file instead of overwritting it. is there  a way?

  • If the error is failing the tests before the Log.SaveAs is being called, then obviously it's not going to save to the log.

     

    You may need to implement an OnStopTest event handler to handle the situations where your normal exception handling doesn't trap such things.  

     

    It appears you have "Stop on Error" or "Stop on Exception" checked in your playback engine.  You might want to consider turning those off as well.

8 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Simple function I used to use,

    function getUniqueName()
    {
    	var indate,inthr,intmi,intsec;
    	indate = aqConvert.DateTimeToFormatStr(aqDateTime.Today(),"%b_%d_%y");
    	inthr = aqDateTime.GetHours(aqDateTime.Now());
    	intmi = aqDateTime.GetMinutes(aqDateTime.Now());
    	intsec = aqDateTime.GetSeconds(aqDateTime.Now());
    	return indate + "-" + inthr + "_" + intmi + "_" + intsec;
    }
    • GAutomation's avatar
      GAutomation
      Frequent Contributor

      a = "result" +Currenttime /log folder stored with current time./ result1536046 is the folder name that gave

      oldFilename = log.path+a(.*)+"\"+"index.htm" /index.htm file is inside the above folder and i gave .* as the current time changes

      newFile name = log.path+a(.*)+"\"+index_current time / new file name given to index

       

      Call aqfileSystem.renameFile(oldFilename, newFilename)

       

      Here .* is not working

      • m_essaid's avatar
        m_essaid
        Valued Contributor

        hi,

        don't use htm format, use packed archive .mht

        you will avoid folder and multiple files.

        then save log with an increment (a date for example)

    • Pbleu's avatar
      Pbleu
      New Contributor

       

      I use the same type of naming conventions for logs  (see shankar_r post above).  Has worked out very well for a number of years as (for those contemplating a strategy):

       

      1. You can easily identify the test
      2. You can easily identify the date/time of execution.  Including seconds, as you have done as well, prevents issues with short test iterations that might be less than a minute apart.

      Just adding my two cents as to why this is a good strategy.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Well, it all depends upon what you're sending to "filename".  That's what determines what the folder is that the file is generated in.  So, it's just a matter of creating some sort of naming scheme that will automatically update each time the log is saved.  We use some concatenation of date and time to give a unique naming convention.