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.js | 17/09/2016 5:19:58 PM | Normal |
| 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.