Log test result to a file
Can someone help me, I am having problems figuring how to do the following:
Using the following data-driven script which compares the captured text "Moving Average" to the expected result kept in the Stores baseline for each patient that is searched. The pass result should be that the text match and is shown as "on" for each searched patient.
Questions:
I would like to log the Checkpoint message to a text file to show "Moving Average" is active the select patient and for the log to contain the verification passed string with the checkmark symbol icon in the Type Column. Can you show me how to add it to the script below?
I would like to show the PatientID for each test result in the log. (example: Patient001has Moving Average active)
Can the result be added to an existing Word document (TestReport.doc), adding it to a new line after a new break page?
//Clicks the 'textboxPatientid' object.
Aliases.browser.pageImagenet.textboxPatientid.Click(44, 9);
//Sets the text KeywordTests.CheckBscan.Variables.PatientID("MaestroPatient") in the 'textboxPatientid' text editor.
Aliases.browser.pageImagenet.textboxPatientid.SetText(Project.Variables.PatientID.Value("MaestroPatient"));
//Clicks the 'buttonAll' button.
Aliases.browser.pageImagenet.buttonAll.ClickButton();
//Clicks the 'cell' object.
Aliases.browser.pageImagenet.cell.Click(93, 11);
//Simulates a left-button double click in a window or control as specified (relative position, shift keys).
Aliases.browser.pageImagenet.panel.DblClick(60, 72);
//Waits until the browser loads the page and is ready to accept user input.
Aliases.browser.pageExam.Wait();
//Clicks the 'vgSvgslice0' object with the right mouse button.
Aliases.browser.pageExam.vgSvgslice0.ClickR(456, 155);
//Clicks the 'textnodeProcessingmovingaverage' object.
Aliases.browser.pageExam.textnodeProcessingmovingaverage.Click(40, 18);
//Clicks the 'vgSvgslice0' object with the right mouse button.
Aliases.browser.pageExam.vgSvgslice0.ClickR(456, 155);
//Clicks the 'textnodeProcessingmovingaverage' object.
Aliases.browser.pageExam.textnodeProcessingmovingaverage.Click(40, 18);
//Checks whether the 'contentText' property of the NameMapping.Sys.browser.pageExam.panelResult.panel object equals 'Moving Average
aqObject.CheckProperty(NameMapping.Sys.browser.pageExam.panelResult.panel, "contentText", cmpEqual, "Moving Average\nClose\nON\n0");
Thank you for your help.
NOTE: You format the string however you need to.
I did the below with commas to use as a way to separate(split) later for
pulling this data for use somewhere else.
The below string contains variables I have set per data collected from the script I ran.//New info for file
resultStr = ""+TFSID+","+T_Result+","+client_version+","+testEnv+","+srtTime+","+stpTime+","+Duration+","+Sys.UserName+","+PCName+","+Sys.OSInfo.Name+","+IEMajorVersion+"\r\n";
//Log.Message(resultStr);
APathFileName1 = "c:\\TCfolders\\TCResults\\TC_Results.txt";
if (aqFile.Exists(APathFileName1))
{
aqFile.WriteToTextFile(APathFileName1, resultStr, aqFile.ctANSI, false);
}
else
{
Log.Message("_TC_Results.txt file not found.");
Log.Message("Creating new file to write to.");
aqFile.Create(APathFileName1);
aqFile.WriteToTextFile(APathFileName1, resultStr, aqFile.ctANSI, false);
}
Once file is created, each time you run the above, it appends to the file for how I
wrote the code above.You want to start with a fresh file, can use the below example code.
function RemoveOldCreateNewReportFiles()
{
var APathFileName1 = "c:\\TCfolders\\TCResults\\TC_Results.txt";
Log.Message(" ");
Log.Message("Running function to delete and create Report files.");
Log.Message(" ");
if(!aqFile.Exists(APathFileName1))
{
aqFile.Create(APathFileName1);
Log.Message("TC_Results.txt did not exist... Creating new file.");
resultStr = "Build,Date,Notes,TestCase,Tester,Verdict\r\n";
aqFile.WriteToTextFile(APathFileName1, resultStr, aqFile.ctANSI, false);
}
else
if(aqFile.Exists(APathFileName1))
{
aqFile.Delete(APathFileName1);
Delay(1000);
aqFile.Create(APathFileName1);
Log.Message("TC_Results.txt existed... Deleted and Recreated new file.");
resultStr = "Build,Date,Notes,TestCase,Tester,Verdict\r\n";
aqFile.WriteToTextFile(APathFileName1, resultStr, aqFile.ctANSI, false);
}
}