For those who use the CreationTime property extensively, you might have noticed a 10-15 seconds delay when working with only 1 open browser. This delay can be avoided, and the answer is quite simple. I am not sure why this approach works whereas CreationTime:=0 fails, but when I find out, I will be sure to update this post. I know that versions 9.5 and 10.0 are being used in many shops, and this is no longer a limitation, but for those who are still using v9.2 (my favorite), this article may help you overcome this issue.
Solution:
Instead of using 0 for Browser CreationTime, use Null. In other words, instead of the usual:
Browser("creationtime:=0")replace the 0 with a null character:
Browser("creationtime:=")To test this, open a single browser, and execute the lines below:
Dim timerInit, timerEnd timerInit = Timer Browser("creationtime:=0").Highlight timerEnd = Timer - timerInit MsgBox "With 'CreationTime:=0' : " & timerEnd & " seconds." timerInit = Timer Browser("creationtime:=").Highlight timerEnd = Timer - timerInit MsgBox "With 'CreationTime:=' : " & timerEnd & " seconds."
Result:
{ 8 comments… read them below or add one }
Hi Anshoo,
Thanks for the great tip, I’ve been frustrated by this behaviour for a while ( I use OR) and this workaround is great.
It’s especially bad if you use a lot of actions as the delay seems to occur at the start of each one!
As noted in the previous comment, it’s an issue in QTP 10, we’re using build 513.
Regards,
Brian
Brian: I didn’t know this issue persists in QTP 10. I used QTP 10 for several months but didn’t see it.. guess I was wrong. Glad its working for you though!!
Hi anshoo,
I can confirm that this issue also affects 10.x.
if it wasn’t for your article, I would have gone completely insane! nice one :)
Thanks for the update! I didn’t know this was affecting QTP 10 as I used it for several months without being able to replicate this issue.. Maybe a new patch broke this again?
Hello anshoo,
Great effort !! let me know that when we can utilize this concept, or when it could be required to take the help of this script.
good bye and take care :)
Thank you, Saurabh.
Well, this concept only comes into play when you decide use CreationTime to identify the browser. Moreover, it only works when you have a single open browser, and using this concept helps avoid the near 10 second delay that you see in the snapshot above.
Hello Anshoo,
This is a fantastic discovery indeed..I think its a performance issue with QTP as the delay is something around 10 seconds as per your screenshot.. Its my first visit also to your website and I am quite impressed.. Great job
Regards,
Yogindernath
Yogindernath,
Thanks for your kind words. I saw your website – it has a lot of great content as well.
Cheers- Anshoo