Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Thursday, September 2, 2010

Mercury Timers Object - The QTP StopWatch


'###############################################
'           Mercury Timers & Timer Object 
'###############################################

'Purpose - To Create a Timer which will work like a stop watch

'We can create multiple Timers using Mercury Timers Object.
'Every Timer can be controlled by Timer Object
' It has some facilities to start, stop, continue and reset the Timers

MercuryTimers("Timer1").Start 'Start measuring time using Timer1. 

Wait 1 

MercuryTimers("Timer1").Stop 'After one second, stop Timer1. 

MercuryTimers("Timer2").Start 'Start measuring time usingTimer2. 

'Two seconds later, restart Timer1 (which will continue to measure time from
'the time it stopped while Timer2 continues uninterrupted). 

Wait 2 

MercuryTimers("Timer1").Continue 

'Three seconds later, stop both timers and send a report to the test
'results specifying the elapsed time for each of the timer objects
'(Timer1 ~4000 ms; Timer2 ~5000 ms). 

Wait 3 

Reporter.ReportEvent micInfo, "Elapsed Time", "Timer1: " & MercuryTimers("Timer1").Stop() & "ms, Timer2: " & MercuryTimers("Timer2").Stop() & "ms" 

'Set a transaction manually for each of the timer objects. Convert the 
'elapsed time for each of the timer objects from milliseconds to seconds so
'the elapsed time will be reported correctly in the transaction. 

Services.SetTransaction "Timer1",MercuryTimers("Timer1").ElapsedTime / 1000,Pass 

Services.SetTransaction "Timer2",MercuryTimers("Timer2").ElapsedTime / 1000,Pass 

No comments :

Post a Comment