Forum Discussion

tandurq_1's avatar
tandurq_1
New Contributor
14 years ago

Getting Pass or Fail result from XML, HTML or MHT report??

Is there an easy way to email a pass or fail result based off the report generated?

Easiest way I can see is to parse the xml report but I can't tell where the result is for the top level.



My scenario:

I run a test project and export the report to xml or html or mht.

Based off that report I generate an email with Pass or Fail in the subject (This is where I'm stuck)



Any help would be appreciated.

4 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    Hi,



    Log object has property ErrCount.



    When you send your e-mail, you can check this property and generate e-mail subject depending on the property value.



    //[JScript]

    var Subject = Log.ErrCount > 0 ? "Failed subject" : "Passed subject"
  • However this only gives the error count for the current test, if you have several tests in the project, you do not get the full count, and would need to parse the log to get it. Or is there a root count available?

  • Hi Mike,





    You can use the following code. It relies on the "RootLogData.dat" file that is generated when you export logs to XML.





    function test()

    {

        var xDoc = new ActiveXObject("MSXML.DOMDocument");

        var path = "Path to RootLogData.dat";

        var file = path+"RootLogData.dat";

        xDoc.load(file);

        xDoc.setProperty("SelectionLanguage", "XPath");

        var id = xDoc.documentElement.selectSingleNode("//Node[Prp[@name='ownermoniker' and @value='']]/Prp[@name='filename']/@value").text;

        xDoc.load(path+id);

        var failedCount = xDoc.documentElement.selectSingleNode("//Node[@name='summary']/Node[@name='failed']/Prp[@name='top-level (sum)']/@value").text; 

        Log.Message(failedCount);

        xDoc = null;

    }