Forum Discussion

oychw's avatar
oychw
Contributor
15 years ago

How can get a project's Error number in JS ?

How can get a project's Error number in JS ?



    There is several items in a project.I want to count how many Errors have occured .

How can get a project's Error numbers in JS ? thanks!

1 Reply


  • Hi,





    Here is the script that counts the total number of errors:







    function GetTotalErrorNumber()

    {

      var tempFolder = aqEnvironment.GetEnvironmentVariable("temp") + "\\" + Math.floor(Math.random() * 10000) + "\\";

      aqFileSystem.CreateFolder(tempFolder);

      Log.SaveResultsAs(tempFolder, lsXML);

      var xDoc = Sys.OleObject("MSXML2.DOMDocument.4.0");

      xDoc.load(tempFolder + "Description.tcLog");

      var errC = VarToInteger(xDoc.selectSingleNode('Nodes/Node[@name="root"]/Prp[@name="error count"]/@value').text);

      aqFileSystem.DeleteFolder(tempFolder, true);

      return errC;    

    }





    function PostSum()

    {

      Log.Message("Error count: " + GetTotalErrorNumber());

    }







    Note that you need to get the total number of errors using the GetTotalErrorNumber function in a routine (in this case, it is PostSum) set as the last test item of the project.