Mercury Timer - QTP

Mercury Timers is a new utility objects that allows you to create various timers. A timer is automatically created when it is first used. An instantiated timer can then be accessed as shown in the following code:

'Get a timer using Timer property
Set newTime= MercuryTimers.Timer("Timel")

Timer is the default property of Mei 'so we don't need to specify Timer
Set newTime= MercuryTimers("Timel")

Mercury Timer object provides following methods:

  • Start: Start the timer
  • Stop: Stop the timer
  • Reset: Reset the timer
  • Continue: Continue a stopped timer
  • ElapsedTime: Time elapsed till last stop (in milliseconds)

The following code shows how to use these methods:

'Start the timer
MercuryTimers("Tiroel").Start
Wait 2
'Stop the timer
MercuryTimers("Timel").Stop
"Print elapsed time - On my machine prints '2012'
Print MercuryTimers("Tiroel").ElapsedTime
Wait 1
'Continue with the timer
MercuryTimers("Timel").Continue
Wait
1
'Print the Elapsed Time - On my machine prints '3014'
Print MercuryTimers("Timel").ElapsedTime
Wait
1
'Stop the timer - On my machine prints '4025'
Print MercuryTimers("Timel").Stop
'Start the timer (this is equivalent to using Reset and then start)
MercuryTimers("Timel"). Start
Wait 2

'Stop the timer
Mercury flaneS^/TImel") .Stop
'Print the elapsed timer - On my machine prints '2012'
Print MercuryTimers("Timel").ElapsedTime
'Reset the timer MercuryTimers("Timel").Reset
'Print the elapsed time - prints '©'
Print MercuryTimers("Timel").ElapsedTime

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

QTP Topics