WaitCell and object does not exist
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
Solved! Go to Solution.
- Labels:
-
Name Mapping
-
Object Recognition
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 Exists
property.
You need to look at Exists so you can capture the failure and go by it
Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I may have no choice in this instance. I cry in the corner each time I delay my tests artificially
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,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
/Alex [Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
-------------------------------------------------
Standard syntax disclaimers apply
Regards,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
[Hall of Fame]
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
