cancel
Showing results for 
Search instead for 
Did you mean: 

WaitCell and object does not exist

SOLVED
Highlighted
Community Leader

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 ?


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
1 ACCEPTED SOLUTION

Accepted Solutions
Community Leader

Re: WaitCell and object does not exist

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 Smiley Very 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...

 

 


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

View solution in original post

15 REPLIES 15
Community Hero

Re: WaitCell and object does not exist

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/web-objects/wait-meth...

Result Value

The method returns web objects of the specified type. If the required object is available before the time elapses, the method returns the object. Otherwise, it returns a stub object. To check if the returned objects exist, use the Existsproperty.

 

You need to look at Exists so you can capture the failure and go by it

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/exists...

 

 

 

Community Leader

Re: WaitCell and object does not exist

Not entirely sure that's quite it.  It's the actual WaitCell(0,0,1000) which is causing the error.  In the next line of code in my watch list, the object I just got from WaitCell is a cell with a .Exists value of true, so it's not that I'm trying to do something with the returned object later and then it doesn't exist.  It's that the WaitCell call says the object doesn't exist, but then happily returns an object that does exist.  Does that mean each time BEFORE I do I need to get the object with a Find([cellproperties],[cellvalues],1000) to check it exists and only then WaitCell(0,0,1000) again for the same object ?  That would really impact performance if I had to search for things twice each time


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Community Hero

Re: WaitCell and object does not exist

Using WaitCell is correct, but if you're saying that WaitCell fails and then right after that the cell Exists, what happens if you just make WaitCell wait a little longer?  It might be too long sometimes but it would catch the occasional failures.

 

We had enough of those kind of errors that I actually ended up slowing the whole test run down just a little so it wouldn't just run in 60 secs and fail miserably.

Community Leader

Re: WaitCell and object does not exist

Sorry, I mistyped.  All those 1000 delays are 10000.  New strategy:

 

 

var waitCell = grid.WaitCell(0,0,100);
var waitloops = 0;
while(!waitCell.Exists && waitloops < 100)
{
	waitloops++;
	waitCell = grid.WaitCell(0,0,100);
	if(waitCell.Exists)
		break;
}

That way it still leaves 10 seconds, but might pick it up sooner.  If it still doesn't exist after 10 seconds, well, the problem is with th speed of the page.  On the other hand, if it's something internal to WaitCell() it won't make any difference to the error.  It may even cause it to happen multiple times.  I'll let you know how it goes...


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Community Hero

Re: WaitCell and object does not exist

Yeah, the speed of the page is why I had to slow the whole thing down.  The first time in we were loading tons of data and even though to the user it looks done (and therefore to TC), it wasn't and the test needed to wait.  I didn't want to put loops like you have in a million places in the code so we used this:

 

https://support.smartbear.com/testcomplete/docs/testing-with/running/tips/changing-speed.html

Community Leader

Re: WaitCell and object does not exist

I may have no choice in this instance.  I cry in the corner each time I delay my tests artificially Smiley Sad

 

As to building in loops everywhere.  Here's my plan

 

I have a "Common" scrip which holds all the small little bits and bobs that I use often.  So in my common script I create a function 

 

function WaitRapper(waitType, waitObject, arguments, overrideWaitInterval, overrideRetries) //I'm a child of the nineties, so I'm more into electronic dance music, but WaitEDM just isn't as catchy
{
	var requiredRaitInterval = (overrideWaitInterval==null || overrideWaitInterval==undefined) ? 100 : aqConvert.VarToInt(overrideWaitInterval);
	var requiredRetries = (overrideRetries==null || overrideRetries==undefined) ? 100 : aqConvert.VarToInt(overrideRetries);
	var retryCount = 0;
	var returnObject = null;
	
	switch(aqString.ToUpper(aqConvert.VarToStr(waitType)))
	{
		case 'CELL':
			returnObject = waitObject.WaitCell(aqConvert.VarToStr(arguments[0]),aqConvert.VarToStr(arguments[1]), requiredRaitInterval);
			while(!returnObject.Exists && retryCount < requiredRetries)
			{
				retryCount++;
				returnObject = waitObject.WaitCell(aqConvert.VarToStr(arguments[0]),aqConvert.VarToStr(arguments[1]), requiredRaitInterval); //The arguments needs to be an array
				if(returnObject.Exists)
				{
					break;
				}
			}
			break;
		case 'TABLE':
			returnObject = waitObject.WaitTable(aqConvert.VarToStr(arguments), requiredRaitInterval);
			while(!returnObject.Exists && retryCount < requiredRetries)
			{
				retryCount++;
				returnObject = waitObject.WaitTable(aqConvert.VarToStr(arguments), requiredRaitInterval); //The arguments has to be a string
				if(returnObject.Exists)
				{
					break;
				}
			}
			break;
			default: 
				returnObject = waitObject.WaitTable(aqConvert.VarToStr(arguments), requiredRaitInterval);
				while(!returnObject.Exists && retryCount < requiredRetries)
				{
					retryCount++;
					returnObject = waitObject.Wait(aqConvert.VarToStr(arguments), requiredRaitInterval); //The arguments has to be a string with the object name
					if(returnObject.Exists)
					{
						break;
					}
				}
			break;
	}
	
	return returnObject;
}

Now, wherever I need to wait:

 

//USEUNIT Common

grid.RefreshMappingInfo();

var waitCell = WaitRapper("Cell",grid,[0,0]);	

if(waitCell.Exists)
{
....
Now to figure out where the coffee has gone...

-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Community Hero

Re: WaitCell and object does not exist

Hi,

 

> I can sort the grid, so need to refresh the mapping 

Just a wild guess as I don't know what and how is implemented in your tested application:

-- Might it be that sorting or some other action makes the grid itself to be recreated within the page DOM? (Possibly, with additional delay to request and populate the grid with data.)

If the above guess is correct, then the problem may be not with the Cell object, but with grid one. (Because of been accessed via Aliasing/Namemapping the grid object will be cached by TestComplete and not destroyed when the script on the page modifies the DOM.)

To verify the above idea, try something like this:

Either

grid.RefreshMappingInfo();

grid.WaitProperty('Exists', true, 10000);

or

grid = Aliases.<IntermediateObjects>.WaitAliasChild('grid', 10000);

 

and then

grid.FindChildEx(…)

 

Does the above help?

 

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Leader

Re: WaitCell and object does not exist


Might it be that sorting or some other action makes the grid itself to be recreated within the page DOM? (Possibly, with additional delay to request and populate the grid with data.) 


Based on all the other errors I was getting with objects being null, disconnecting from invoked etc, I'm convinced it does, which is why I'm always doing the RefreshMappingInfo();

 

I didn't think a mapping info refresh would cause an object to actually stop existing, but I guess it makes sense.  I'll go with grid.WaitProperty, since my grid isn't a direct child of an aliased object.  Back in a bit Smiley Very Happy

 


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Community Hero

Re: WaitCell and object does not exist

Actually... I wonder if it's the grid itself that doesn't exist when calling "WaitCell".  If that's the line that's generating the error, then WaitCell itself is not the problem, it's the grid object that's the problem.

Where is the line of code that is assigning the value to the "grid" variable?  That's where you need to put "wait" code in... to wait for "grid" to exist first using a FindChild or WaitChild or something similar.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available