Forum Discussion

mgreen's avatar
mgreen
Contributor
6 years ago
Solved

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 wi...
  • tristaanogre's avatar
    6 years ago

    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")