Forum Discussion

rhsou123's avatar
rhsou123
Contributor
8 years ago
Solved

How to calculate Time in Testcomplete ?

Hi,

 

please how can I calculate Time using Vbscript in Testcomplete ?

 

I need the equivalent of  these two code line please.

                         '**************Calculating Time*************
	                                MercuryTimers("Timer").Stop
	                                MercuryTimers("Timer").Start
	                    '*******************************************

5 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Hi,

     

    You can use aqDateTime object:

     

    Sub Timer
    
        Dim t1, t2
        t1 = aqDateTime.Time
        aqUtils.Delay(2000)
        t2 = aqDateTime.Time
        Log.Message("Time difference: " & aqConvert.DateTimeToFormatStr(t2-t1, "%H:%M:%S"))
        
    End Sub 

     

    • rhsou123's avatar
      rhsou123
      Contributor

      Thank you, I find this too

       

      aqPerformance.Stop()

       

      aqPerformance.Start()

       

      does these methods do the same thing ?

       

      I need the time to be calculated when the script is running.

      • baxatob's avatar
        baxatob
        Community Hero

        Yes, you can do it using aqPerformance object, too. However it is not 100% exact, usually it takes few extra milliseconds to launch itself.

         

        Only note - there is no Stop() method, use Value property instead.

  • This is basic stuff you can find in the online documentation or via the "Help" menu in TestComplete itself.

     

    https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/methods.html

     

    Var1 = aqDateTime.Time

    >>> Do whatever you need to do <<<

    Var2 = aqDateTime.Time

     

    VarDiff = Var1 - Var2

     

    Would be one way. There are many others.

     

    You could use the built in VBScript one.

     

    https://msdn.microsoft.com/en-us/library/a3fb2dtc(v=vs.84).aspx

     

    Var1 = Timer

    VarDiff  = Timer - Var1

     

    Like I say. This is basic stuff. Loads of ways to do it.