Forum Discussion
tristaanogre
14 years agoEsteemed Contributor
The WaitProperty method returns a boolean true or false if, after the timeout, the property successfully was assigned the value. So, what you can do is use a while loop dependant upon that result. something like
My only problem with infinite loops is that they are infinite. At some point in time, if the property does not equal the desired value, you'll want to break out of the loop and say "We didn't get there" and record an error. After all, isn't that essentially a bug in the code that you're expecting the property to turn to true and it never does?
So... instead of an infinite loop, you can just set the timeout to a sufficiently high value... say, two minutes (120 seconds). The code, then, would look like
If it takes longer than two minutes for an object to be enabled, usually, to me, that presents a problem towards usability of the application under test.
But, YMMV.
while (!Aliases.MainWnd.TabBar.TabbtnPlanContent.WaitProperty("Enabled", true, -1))
{
Delay(500)
}My only problem with infinite loops is that they are infinite. At some point in time, if the property does not equal the desired value, you'll want to break out of the loop and say "We didn't get there" and record an error. After all, isn't that essentially a bug in the code that you're expecting the property to turn to true and it never does?
So... instead of an infinite loop, you can just set the timeout to a sufficiently high value... say, two minutes (120 seconds). The code, then, would look like
if (!Aliases.MainWnd.TabBar.TabbtnPlanContent.WaitProperty("Enabled", true, 120000)) then
{
Log.Error("The object never got enabled")
}
else {Aliases.MainWnd.TabBar.TabbtnPlanContent.Click()}
If it takes longer than two minutes for an object to be enabled, usually, to me, that presents a problem towards usability of the application under test.
But, YMMV.