QTP 9.2: Delay Using CreationTime:=0 With 1 Open Browser

by Anshoo Arora ON August 24, 2009 · Posted In All, QTP · 8 comments

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:

CreationTime = 0 CreationTime =

Subscribe to Relevant Codes (by Anshoo Arora)

Hello! We're always posting interesting articles on Relevant Codes. Why not subscribe so you don't miss out?

Leave a Comment

{ 8 comments… read them below or add one }

Brian June 20, 2011 at 12:56 pm

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

Reply

Anshoo Arora June 24, 2011 at 11:10 am

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!!

Reply

c macdonald February 1, 2011 at 9:59 am

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 :)

Reply

Anshoo Arora February 19, 2011 at 7:02 am

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?

Reply

saurabh September 29, 2009 at 6:33 am

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 :)

Reply

Anshoo Arora September 29, 2009 at 6:52 pm

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.

Reply

Yogindernath August 30, 2009 at 4:38 am

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

Reply

Anshoo Arora September 4, 2009 at 5:17 pm

Yogindernath,

Thanks for your kind words. I saw your website – it has a lot of great content as well.

Cheers- Anshoo

Reply

Previous post:

Next post: