5

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?

Michael Innes
  • 2,045
  • 5
  • 25
  • 41

5 Answers5

3

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
Gilad
  • 31
  • 2
0

Make sure you don't have "Smart Identification" enabled for the test object in the Object Repository. That can get in the way.

BrianJM
  • 301
  • 1
  • 7
  • I checked each of the WPFbutton objects that I'm having problems with; turns out they have Smart Identification turned to `False` and also grayed out. – Michael Innes Jan 18 '13 at 01:19
  • What about for the parent objects? In the Test Results, are there any indications that Smart Identification is being used? – BrianJM Jan 21 '13 at 15:51
  • The parent object doesn't have Smart Identification on either. Testing for the existence of the parent window is very fast (and the parent does exist). – Michael Innes Jan 30 '13 at 22:42
0

The additional time that you're encountering is the default timeout setting, which is set to 20 seconds by default. Any Wait or Exist timers will stack on top of the default timeout.

It can be changed in the test settings:

Test Settings > Run > Object synchronization timeout - set in seconds

or in the vbscript:

Setting("DefaultTimeout") = 4000 'set in milliseconds
kleopatra
  • 51,061
  • 28
  • 99
  • 211
  • But shouldn't me passing a Timeout Parameter _override_ the default timeout setting for this .Exist? I mean, that's the whole point of passing a number for the .Exist statement, isn't it? Why is my timeout parameter being _added onto_ the default timeout instead of replacing it? – Michael Innes Sep 05 '13 at 22:03
0

Using DefaultTimeout function at the beginning of the driver script would be sufficient .

Setting("DefaultTimeout") = 10000   'set in milliseconds

If any object exceeds the timeout limit of 10 seconds as mentioned above then the object will fail to get captured and Run Results will show a failure

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
0

I would recommend going by with just the default timeout. Using .Exist(x) will use the mentioned time for each child.

Ravi
  • 29
  • 1
  • 5