Forum Discussion
Kinda using something like this in many of my scripts (jscript), which works like a charm and you're able to give a maximum waiting time.
function WaitForObject(Object, MaxWait) { for (var i=0;i<MaxWait;i++) { if (Object.Exists) { if (Object.VisibleOnScreen && Object.Enabled) { Log.Message("Object found & enabled on screen!");
return Object; } } }
Log.Error("Object not found in max number of iterations!"); return false; }
How do you guys handle errors that go to the Log?
I would love to see my test green, but with checking while an element is visible or not visible I am getting this red error signs there, while overall test passes.
- marinb8 years agoContributor
Never try to execute actions on objects that may not exist yet.
so no
x = <function/command to find the object>
x.click
but
x = <function/command to find the object>
if (<check if x exists returns true>)
{ x.click }
else
{ Log.Error("Couldnt click x because the object was not found") }
Could be that the various TestComplete built-in checks like CheckProperty returns errors when they fail, but I try to refrain from using them unless they don't fill my log with green checks or red errors.
- tristaanogre8 years agoEsteemed Contributor
What marinb said... Unless you can pretty much guarentee the object will be there, don't attempt to do anything until it is.
If you're using NameMapping, there's a built-in auto-time out (defaults to 10 seconds) so you might be able to get away with standard functionality. But if you're performing some action and then checking to see if some other result happened, it's always a good idea to use WaitNNN methods or "FindChild" methods to look for the object and then check the result of that method to determine if it was successful.
Related Content
- 5 months ago
- 2 years ago
Recent Discussions
- 50 minutes ago
- 2 days ago