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 experiencing. Short summary: if I use WaitCell, very occasionally the WaitCell call itself causes "The object "Cell(0,0) does not exist" error. The test will continue running, but because there's an error, the test is marked as failed.
the code:
grid.RefreshMappingInfo(); // I can sort the grid, so need to refresh the mapping just in case, else the mappings will be broken var waitCell = grid.WaitCell(0,0,10000); //The object doesn't exist and is output to the error about 0.5 seconds after the call
grid.FindChildEx(… //this works again
I'm using it as a way to confirm that RefreshMappingInfo()has completed before I try and use Find methods again. At worst it should return a stub, right ?
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&¤Tier<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...