Forum Discussion

LoneWanderer04's avatar
Occasional Contributor
4 years ago

Reliable way of performing action if element exists without failing if it doesn't

Hello everybody!


This is my first time I've really used TestComplete as the main test engine, with my previous background being in Selenium.  When I used that, if I needed to do an action on an element that might or might not exist (like closing a window if displayed first), I'd just do a simple "if all(*element identifier*).length > 0" or something similar, which would give me a 0 if it didn't exist, and greater if it did, so it wouldn't fail out.

Is there some similar way in TestComplete to basically have a basic check to see if an element is present so I can do an action if it is, and just ignore the next code if it isn't?  I've tried FindElement, WaitChild, etc, and all those don't seem to be doing quite what I expected.

2 Replies