We have scenarios in out scripts where the system may take a varied amount of time moving or returning to a screen.
The problem was occurring that there were a few Object not found exceptions thrown as a result.
I was looking to add in some effective synchronisation into the scripts, in particular where VPs are carried out in the Common script, or record numbers were extracted from screens for later use. I tried the waitForExistence to reduce the timing error we were getting.
I have had some success on this with commands like
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">//Seconds used from the Pref/Settings/Playback settings.
objectname().waitForExistence();</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">From what I can see though, if for example it performs the check every seconds for 20 seconds (the default setting) and doesn’t find the object, an exception is thrown. What I am not sure of though is if say it finds the object after 2 seconds, does it wait for the other 18 seconds or not.
I need something that will wait only until it is found, but from what I can see, it seems to slow the scripts down, and only add some benefit.
What I’d like to do following the logic I would use on other tools is:
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">//pseudocode
</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">thus not relying on any timeout parameters.
Anyone have any ideas, or came across any similar issues?
Look in Windows~ Preferences on the Playback branch.
The Maximum time to attempt to find an object parameter does wait 20 seconds by default.
The parameter below that is the "Pause between attempts to find..." parameter. Since is is waiting one second by default, it will test for the window 20 times before reporting an error.
This has been my experience. In your example it should wait 2 seconds and then (after a delay to unwind the stack) continue with the script.
I have seen problems. Mainly, when the programmers use a list box like it was a frame. They put a list box on the page (with scroll bars) and then proceed to load the list with all the content.
If the object is in a frame and not visible (off the page) then happily the object search function works. If the object is in a list (and not visible) the object search function can not see it and fails. This List as Frame pattern has been used a lot in the recent past. Thankfully it seems to be going away. You may not have this exact problem, but perhaps a new version of it.
In SilkTest, this is accomplished like this (probably easy to convert to RFT). Excuse my rough pseudocode.
<font class="small">Code:</font><hr /><pre>
int tries = 0;
if (tries < 10)
Hope this helps. Not sure if waitforexistance can take a param specifying the timeout. If not, you set the global setting at 1.