TestComplete will not go to Else - just throws error
Been experiencing some wierd issues with my IF statements lately in testcomplete..
IF the statement IS NOT true I will get an extremely long hang/timeout, or in this case with the code below, I will just get a error in log saying "object doesnt exist" when it is obvious that I want it to go to ELSE.
Any advice for this? thanks
if (Aliases.browser.webpage.cell0_grid.link.VisibleOnScreen == true)
{
Log.Message("Item ID is visible on screen")
} else {
Log.Message("Item ID is NOT on screen")
If the object does not exist, the first thing that it will attempt is to check existance before it attempts the "else". That's why you're getting that error. If there is the liklihood that an object may not exist when you go to access it, you should always check for existance first before you perform the action. "VisibleOnScreen" might not be the best property to check in your case. Exists migtht be a better check. Try the following code.
if (Aliases.browser.webpage.cell0_grid.WaitAliasChild('link', 30000).Exists) { Log.Message("Item ID is visible on screen") } else { Log.Message("Item ID is NOT on screen")