Wait timeout and waitproperty not working as expected
I need some help figuring out what I’m doing wrong with setting the timeout values in testcomplete. First, the only reason I’m creating the type of function below is that the WaitProperty does not do what it’s supposed to.
Anytime I have ever used WaitProperty, it waits the ENTIRE time value that is specified in the WaitTime parameter. So if I tell it to wait 30 seconds for an onscreen object’s visible property to be true
SomeObj.WaitProperty(“Visible”, true, 30)
And it is visible on the screen in just 5 seconds, it’s still going to wait the full thirty seconds before allowing the execution to continue. If smartbear would just fix this then that would really simplify my life. I don’t see why this should be such a problem to resolve. I can put a two minute wait time in the WaitWinFormObject method and if the form that has been specified in the method exists in 5 seconds in doesn’t wait the full two minutes.
So, back to the issue I’m having with my home grown property wait function. Here is the essential part of what it does. I pass in two arguments the object and an integer value of how long I want it to wait for the exists property to be true before it gives up.
function CheckForExists(objElement, intSecondsToDelay)
{
let intTimeOut = Options.Run.Timeout;
Log.Message("Check for exists " + Options.Run.Timeout);
Options.Run.Timeout = 1000;
Project.Variables.blnWindowFound = false;
let intSecondsWaited = 0;
Log.Message("starting do loop");
do
{
intSecondsWaited ++;
Log.Message(Options.Run.Timeout);
if (objElement.Exists)
{
Log.Message("object exists");
Project.Variables.blnWindowFound = true;
break;
}
else
{
Log.Message("object does not exist");
}
Log.Message(intSecondsToDelay);
Log.Message(intSecondsWaited);
}
while (intSecondsWaited <= intSecondsToDelay);
Here’s the line in my keyword script that calls this function. I am passing in the object name and an integer 15 for the number of seconds to wait.
As you can see, in addition to setting the Options.Run.Timeout value inside the function to 1000ms, I’m even putting 1000ms in the Autowait timeout value of the function call in the keyword test because I want each iteration of the Do Loop inside the function to only take one second as it compares it to the value of 15. Despite all that, for some reason, when it’s checking the Exists property of the object, it is taking more than 30 seconds for each iteration.
Does anyone see anything that I’ve messed up here or can someone tell me why the testcomplete WaitProperty method doesn’t work like it’s supposed to?
Thanks!
Hi,
> Anytime I have ever used WaitProperty, it waits the ENTIRE time value that is specified in the WaitTime parameter.
Can you provide a real code snippet that does not work as expected?
There are questions for your CheckForExists() function but I would like to see the non-working code first.