Forum Discussion

madhavisri01's avatar
madhavisri01
Contributor
14 years ago

Get the Execution time (Start and End Time)

Hello,



I am trying to get the below Information once the Test Suite Execution is completed.Is their any built in function available?

1.Start and End time of Test execution once

2.Run time

3.File name

4.No.of Errors

5.No.of Warnings

6.Duration taken to complete the Test Suite Execution(Diff between start and End time)



Can anyone help me how to get the data?



Thanks,

Madhavisri




6 Replies

  • gentlesea's avatar
    gentlesea
    Frequent Contributor
    The solution was found by a colleague: msxml.msi was missing. Get it here.

  • Hi Madhavisri,





    You can get this information using the script below:

    function getResults()

    {

      Log.Message("See Information data in the Additional Info panel", getInformationData());

    }





    function getInformationData()

    {

      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");





      // Warning count

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





      //Error count

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





      //Execution time

      var startTime = VarToFloat(xDoc.selectSingleNode('Nodes/Node[@name="root"]/Prp[@name="start time"]/@value').text);

      var stopTime = VarToFloat(xDoc.selectSingleNode('Nodes/Node[@name="root"]/Prp[@name="stop time"]/@value').text);





      aqFileSystem.DeleteFolder(tempFolder, true);

      

      var res =

        "Errors: " + errC + "\r\n" +

        "Warnings: " + wrnC + "\r\n" +

        "Start Time: " + DateTimeToStr(startTime) + "\r\n" +

        "Stop Time: " + DateTimeToStr(stopTime) + "\r\n" +

        "Run Time: " + aqConvert.DateTimeToFormatStr(stopTime - startTime, "%H:%M:%S");

      return res;    

    }
    • hhagay's avatar
      hhagay
      Contributor

      Hello Dmitry

       

      Trying to implement your code I received this error message

       

      Error Invalid class string: cannot obtain ClassID.

       

      I was hoping you could shed some light on it.

       

      Thank you

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        That error is generated by the line that calls Sys.OleObject("MSXML2.DOMDocument.4.0")

         

        Basically, it means that, in your environment, that particular MSXML object does not exist.

        Try changing the code to simply Sys.OleObject("MSXML2.DOMDocument") and leave the version information off the end. That MIGHT fix it.

  • gentlesea's avatar
    gentlesea
    Frequent Contributor
    Thank you for this code. I am using it on different machines. On my machine it runs perfectly. But recently we installed 2 more machines and on them the following command produces a JScript error:





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





    What can be the cause of this problem? I guess some libraries are missing, am I right?

  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Hello i need the same along with



    •   Test duration




    •   Total Project Test Items




    •   Executed Project test items




    •  Passed and Failed test item count.


    how to get it from log file



    [Equivalent VBScript for above example]



    function getResults()

     

     Log.Message "See Information data in the Additional Info panel",  getInformationData

     

    End function

     

     

     



     

    function getInformationData

     



     tempFolder = aqEnvironment.GetEnvironmentVariable("temp") & "\" & Int(rnd * 10000) & "\"

     

      aqFileSystem.CreateFolder(tempFolder)

      Log.SaveResultsAs tempFolder, lsXML

     

      Set xDoc = Sys.OleObject("MSXML2.DOMDocument.4.0")

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

     

     

     

     

     

     ' // Warning count

     

      wrnC = VarToInteger(xDoc.selectSingleNode("Nodes/Node[@name='root']/Prp[@name='warning count']/@value").text)

     

     

      '//Error count

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

     

     ' //Execution time

     

      startTime = VarToFloat(xDoc.selectSingleNode("Nodes/Node[@name='root']/Prp[@name='start time']/@value").text)

     

      stopTime = VarToFloat(xDoc.selectSingleNode("Nodes/Node[@name='root']/Prp[@name='stop time']/@value").text)

     

     

      aqFileSystem.DeleteFolder tempFolder,true

     

      getInformationData = "Errors: " & errC & vblf &_

       "Warnings: " & wrnC & vblf &_

       "Start Time: " & DateTimeToStr(startTime) & vblf &_

       "Stop Time: " & DateTimeToStr(stopTime) & vblf &_

       "Run Time: " & aqConvert.DateTimeToFormatStr(stopTime - startTime, "%H:%M:%S")

     

    End function