I am trying to record one test case. After recording if I play back test case is getting failed.
Property chek points and some clicks functions are getting failed. I tries to hightlight perticular property on screen then it is showing "Unable to highlight the selected object on screen".
I am facing this problem frequntly. If i try to run one week old recorded test cases also same problem i am facing.
If I run all smoke test cases, half of the test cases are getting failed because of this error(Object doesn't exist).
But the object is present in Name mapping editor.
Could please anyone help me do I need to take any precautions to avoid this problem?
Kindly tell me the possible reason for this error.
Thanks in advance.
Solved! Go to Solution.
The reason is simply this:
Recording a test is a good STARTING point. Once the test is recorded, there are at LEAST two things you need to do, and they are not necessarily simple.
1) Examine/evaluate what was mapped during the recording. Many times, objects have identifying properties that are dynamic and change from execution to execution and you will need to make modifications, updates, even completely remap objects and their hierarchy in order to more reliably identify the object.
2) Examine/evaluate the execution of the test case recorded with an eye towards timing issues. Many times TestComplete will attempt to move forward to the next step/line of code before the application is ready to be interacted against. Pages need to load, client-side components need to resolve/render, behind-the-scenes data needs to compile, etc. Liberal use of "wait" methods (do a search in the help for "waiting for objects") will help resolve this.
There may be more, but this is the starting point. Basically, record/playback for test automation in this day and age of complex applications is not a reliable means for creating a reusable and robust test scenarios, ESPECIALLY with regards to web applications.
Thanks for the reply.
What ever i tried their is no dynamic properties.
what I understand is in my name mapping object so many 'panel' and 'cell' object are there.
While running the script some times TC is not able to find the correct object. I tried for editing the properties for those objects. but i am not having properties to find uniquess. Every cell and panel having same properties.
While recording we will think new object but internally it is mapping to existing object.
Beacuse this also my test cases are getting failed.
How can we make sure the uniqueness of the object?
I have run into this problem as well. For a long term solution you should talk to your development team and show them the problem. Encourage them for any new development to start adding unique identifiers such as object IDs, classes, object names, etc.
For me I found this problem was compounded when my namemapping is flat instead of many layers.
I attached an image of one section of my namemapping file with many levels. This section has mostly tables and cells with no unique IDs. the top most object has attributes ObjectType = Page, ObjectGroupIndex = 0 and a URL reference in the form of:
The astrix allow for running on multiple sites and eliminates problems with changing page attributes that might be added to the URL as the page is navigated.
A flat namemapping would be like:
Instead I would use:
By examining the properties of the object... This takes elbow-grease and work. You need to go down the line of those panels and cells and make sure that any properties automatically mapped are enough... and if they are not, manually add them. There is an "art" to this... and it does take time. I cannot tell you EXACTLY what to do... because only you can see those properties and know what your application looks like.
Again.... as noted... after recording, you should examine what was mapped and make changes.... and that means make changes the WHOLE WAY DOWN THE OBJECT TREE. Because the error may not be on the TARGET object but on some ancestor.
Some of us actually make a point that, before recording, map the objects manually first. Take the time to build your mapping of your objects BEFORE you hit the record button. The recording will then use the already-mapped objects instead of mapping new ones.... that is, so long as you did the job right.
Actually, even for that final table, I might even, personally, add some additional identifying factors... is there an ObjectIdentifier that will help distinguish it from other tables? What about static content (column headers) if present? Considering using things like "Required Children" and "Conditional Mapping" to help alleviate some of the ambiguity... but yes, I agree, to your tree structure.
Also, make use of Aliases. Your NameMapping may be something like
You don't have to include that WHOLE tree in your code... using Aliases, you can "collapse" this down to simply be
Also, having worked with DevExpress, there are some elements that have no way of uniquely identifying them. e.g. the expand button on each line of a grid is just an image called img. In these cases you may get an object doesn't exist if you are lucky. Other times it gets entirely the wrong object and your test goes horribly wrong and falls over way downstream at a place that has no relation to where your test actually went wrong. What you could do is to map one or more items between your top level and your object - manually through object borwser - which does have a way of being uniquely identified through, say object type and object name. From here you can map your non-unique sub-object. In the above example, I would map the table, then the cell that holds the image. Now that I have that, theres only one object in my mapped object's children that's called img. At this point, you can go further and follow @tristaanogre's suggestion to shorten the Mapping through Aliases to make it easier to read/type/use
Just for an illustration. This is a bit of what the structure of one of one of my pages look like:
Notice Panel(0) exists on each tier. If you inspect them, the only thing that's unique is their contentText - and that changes dynamically. They even have the "same" children according to TC. Each Panel is unique on their tier of the hierarchy though. That means that if you map top level Panel(0), finding Panel(0) on the next tier is easy, becaue it is Unique within that...
Thanks everyone for the help!
@nakshatra, did the suggestions help you find the solution? please share it with us.