How does the .Exist timeout work within QTP?

Eptin picture Eptin · Jan 17, 2013 · Viewed 26.4k times · Source

I've worked with the .Exist method quite a bit, but I recently moved to a new project (now using a WPF application) with QTP 11 (whereas previously I had QTP 10).

Now I'd like to check that a message does not exist by using object.Exist(2). Weirdly, I only get a result after ~23 seconds, instead of the 2 seconds I was expecting.

How does the timeout work? In previous projects, using object.Exist(2) would wait 2 seconds before determining that the object didn't exist. The QTP help file also says it should only wait for 2 seconds (the specified timeout parameter). Now, it seems as though it's waiting for the Timeout Parameter (2 seconds) AND Object Synchronization Timeout (20 seconds).

Also, Smart Identification is disabled, so it shouldn't be waiting for that. Highlighting the object using the Object Repository instantly says the object doesn't exist.

Has the timeout behavior changed between QTP v10 and v11? Why does it take so long to say an object doesn't exist?

Answer

Gilad picture Gilad · Feb 16, 2015

The Exist method does not work for the last object only. It works hierarchically - which means this method checks each parent object before checking the last one. The timeout only works for the last object. if you want to receive the answer immediately, I suggest you use the following code-

if WPFWindow("x").Exist(0) Then
   if WPFWindow("x").WPFButton("y").Exist(0) Then
     'action 
   End if
End if