Forum Discussion

RUDOLF_BOTHMA's avatar
RUDOLF_BOTHMA
Community Hero
6 years ago
Solved

WaitCell and object does not exist

Afternoon folks,   I'm running into an intermittent issue I hope have you have ideas about.   There are loads of questions that are ALMOST the same, but none of them seem to be quite what I'm exp...
  • RUDOLF_BOTHMA's avatar
    RUDOLF_BOTHMA
    6 years ago

    Edit: clarified code.

     

    Well, after extensive testing I can say that the issue is gone.  The changes I made as a result of this thread has both made my scripts faster and more reliable - thanks :smileyvery-happy:  It didn't resolve the majority of the issues though.  I finally found what is causing the majority of the errors and it has nothing to do with this.  The problem lies with this piece of code that posts an image of a parent of the tested object because sometimes just seeing a blank textbox doesn't mean anything:

    WriteAnEntry(Aliases.browser...MyTextBox,"I'm writing to the textbox",3);
    
    function WriteAnEntry(aliasObj,messageText,addPicture,moveXTiersUpforPicture)
    {
    	if(aliasObj===null || aliasObj==undefined || !aliasObj.Exists)
      {
        Log.Message(messageText);
    		return;
      }
    	
    	var imageobject = aliasobject;
    	var currenTier = 0
    	if(addPicture)
    	{
    		while(imageobject!=null && imageobject!=undefined&&currenTier<moveXTiersUpforPicture)
    		{
    			if(imageobject.ObjectType!="Form") //Don't go TOO high'
    				break;
    	
    			currenTier++;	
    			if(imageobject.Parent !=null && imageobject.Parent !=undefined && imageobject.Parent.Exists)
    			{
    					imageobject = imageobject.Parent;			
    			}	
    		}	
    	}
    var testtheobject = imageobject!=null && imageobject!=undefined&& imageobject.Exists;
    //testtheobject is true now //nowhere in the above code do I ever allocate a null/undefined/!exists to my imageobject var //but, very occasionally when I do the following call, the image object is gone, //so it's the testing for null or undefined causes the error Log.Message(messageText,"", pmNormal, "",(addPicture && imageobject!=null && imageobject!=undefined ) ? imageobject:""); }

    So, how did I fix it ?  Try.. Catch

     

    var canDoImage = null;
    		var placeholderObj = null;
    		try
    		{
    				placeholderObj = (imageobj!=null && imageobj!=undefined && imageobj.Exists) ? imageobj : null;
    				if(placeholderObj==null)
    				{
    					canDoImage = false;    
    				}				
    		}
    		catch (e)
    		{				
    				canDoImage = false;    
    		}
       
        Log.Message(messageText,"", pmNormal, "",(canDoImage && placeholderObj!=null ) ? placeholderObj:null);

     I have NO idea how that object gets lost, but there you have it...