QTP vb scripting timer function:
Hi Friends I am going to share one another qtp vb script function with you and one advance tips of of QTP that you will find very helpful.
Following function (CallTimeSeconds) will give you time duration of your qtp script execution in seconds.You can modify this function if you want time duration in minutes.
StartHour = Hour(StartTime)
StartMin = Minute(StartTime)
StartSec = Second(StartTime)
EndHour = Hour(EndTime)
EndMin = Minute(EndTime)
EndSec = Second(EndTime)
StartingSeconds = (StartSec + (StartMin * 60) + (StartHour * 60))
EndingSeconds = (EndSec + (EndMin * 60) + (EndHour * 60))
CallTimeSeconds = EndingSeconds – StartingSeconds
Now write following line at the start of your qtp script.
StartTime = Now ‘This command will give you present system time.
then write Following lines at end of your qtp script.
EndTime = Now
TimeDiff = CallTimeSeconds(StartTime,EndTime)
msgbox TimeDiff ‘You will get time duration in this message box.
You can modify this script according to your needs and requirements.You are always welcome to if you find any issue with qtp.
I have already share one tips with you now I am going to share one another tips and tricks.
QTP tips and tricks-2:
If you want to get host name (machine name) of your machine at run time at which qtp is installed.
You can get it programmatically through qtp.
Just write following line in your script.
Set WshSystemEnv = WshShell.Environment(“USER”)
machine = WshSystemEnv(“machine name”)
If you have any tips and tricks of QTP you can also share with us.