cancel
Showing results for 
Search instead for 
Did you mean: 

Stop Watch string object

Highlighted
Contributor

Stop Watch string object

I get the time in milliseconds from -

 set StopWatchObj1 = histuils.stopwatch

stopwatchobj1.tostring

I need to store this in a excel sheet so I use the function aqtime.writetotextfile to write it in a .csv file which I can open in excel. 

The resut of stopwatchobj1.tostring in the .csv file when I open as text file shows the right string "0:00:02:690".

When I open the same in excel, I see the result as 00:00:2



Is there a way I can get the same format in excel??
6 REPLIES 6
Highlighted
Occasional Contributor

RE: Stop Watch string object

If you're using that Excel sheet just to manually view the values which
TC has output, then you can change the cell formatting in Excel by going
to Format -> Format Cells... (keyboard shortcut "Ctrl + 1").  On the "Number" tab choose the "Custom" option, and then on the right in the "Type" textbox enter:



  hh:mm:ss.000



Then click OK and it should appear correctly on the spreadsheet.
Highlighted
Contributor

RE: Stop Watch string object

Yeah.. i do that.. but is there a way the enduser can view the same format without doing any workaround..

I have to give my scripts to my client.. when they view the result sheet they should be able to get it.



Thanks for your replly...
Highlighted
Contributor

RE: Stop Watch string object

In that case you'll have to modify the value before it gets written to the csv file. There are two options:

1) Preceed the value with a single quote to force it to be interpreted as a string, as follows:

'0:00:02:690

2) Change the last colon to a decimal point and it should be interpreted as a time, as follows:

0:00:02.690


Highlighted

RE: Stop Watch string object

Hi Madhi,


Please note that this forum is actually for AutomatedQA TestComplete functionality questions, not for questions on Microsoft Excel.


Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Contributor

RE: Stop Watch string object

I understand this forum is not for excel.  My question is totally related to the output from HISUtils stopwatch object



I tried the aqdatetime.Timeinterval to fnd out the difference between the two results i get from stopwatch.  Looks like i need to have date format as well to use the timeinterval method.  Do you have any suggestion to calculate the difference


The output from stopwatch object.tostring is in the format hh:mm:ss.000

Highlighted
Occasional Contributor

RE: Stop Watch string object

You can get the elapsed milliseconds from the StopWatch.Split() and StopWatch.Stop() methods.





JScript:



function StopWatchTest()

{

  var stopWatch = HISUtils.StopWatch;

 

  stopWatch.Start();

 

  Sleep(1500);

 

  var startTime = stopWatch.Split();

 

  Sleep(2000);

 

  var endTime = stopWatch.Stop();

 

  Log.Message("Start time: " + startTime + "ms");

  Log.Message("End time: " + endTime + "ms");

  Log.Message("Duration: " + (endTime - startTime) + "ms");

}
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to pass custom command-line arguments as a test parameter for the TechCorner tag!

Will you dare to take the challenge?


Top Kudoed Authors