Ask a Question

Get the Execution time (Start and End Time)

madhavisri01
Contributor

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 6


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;    

}
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
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?

Using TestComplete 9.0.2460.7
gentlesea
Frequent Contributor

The solution was found by a colleague: msxml.msi was missing. Get it here.
Using TestComplete 9.0.2460.7
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

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
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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: