Ask a Question

Log.SaveResultsAs HTML

SOLVED
DonN
Occasional Contributor

Log.SaveResultsAs HTML

2/ Log.SaveResultsAs HTML works some of the time, but not most of the time. It does work if you run a single test. If you keep writing a new version to the HTML each time you finish a test (in the same way as we  successfully write to lsMHT below), it gets a consistent error like this: 

 

Cannot create file E:\BuildAgent\work\b3356916b7089288\GUIAutomation\SourceUIAutomation\SmokeTests\ExportedLogs\ResultsManager_Stats\RiverOperatorResultsManager\RiverOperatorSmokeTests\General\RiverOperatorCreateNewROProject\ScriptTestLogRO_Create_New_ProjectCreateNewROProject\_TestLog.js17/09/2016 5:19:58 PMNormal

 

 Error

  

Our code looks like this: 

   if (aqString.Find(runName, "Source.mds") != -1)

   {

      // Saves the test results 

      var WorkDir = Project.ConfigPath + "..\\ExportedLogs\\"; 

 

      var FileName = WorkDir + "SmokeTests.mht";

      Log.SaveResultsAs(FileName, lsMHT);  

      

      // Saving as a Web page

      

      var testname = arguments.callee.toString().match(/function ([^\(]+)/)[1];

      

      var PName = Project.FileName;

      Log.Message("PName = " + PName);

      var Name = Project.TestItems.Current.Name;

      var Element = Project.TestItems.Current.ElementToBeRun;

      Log.Message("Name is: " + Name + " and Element is : " + Element);

      WorkDir = Project.ConfigPath + "ExportedLogs\\"; 

      var FileName = WorkDir + Name;

      Log.Message("FileName is: " + FileName);

      Log.Message("Project.ConfigPath is: " + Project.ConfigPath); 

      Log.SaveResultsAs(FileName, lsHTML);  //IfHTML

   

   This fancy code is to try to get around the errors when the command is asked to simply write to the same filename as the MHT one does. First test creates HTML, second test doesn't. 

2 REPLIES 2
dganov
Staff

I faced this issue too and it was related to long file path, which contains test and project item names.

You need to change your test and project item names to be shorter, so that the resulting path will be shorter too.

That's exactly it. The file name in the error above is 270 characters long and Windows only supports a max of 255 characters. It would be nice if the log exporting automatically encoded or truncated file names so this would not be an issue. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
cancel
Showing results for 
Search instead for 
Did you mean: