Forum Discussion
Hello HirendraSingh,
Mostly I am just going to echo what Hassan_Ballan said and toss in a few links....
TC used only property based identification by default in versions 14.50 and prior. XPath and CSS Selectors with conditional statements could only be added manually to the name map if enabled. However this isn't the case now. Adding an XPath or CSS Selector changes the way objects are identified as you have found. The fact that you have to add these manually as a work around likely means it was disabled at some point, is not enabled now, or the project was coded without this enabled and you are now going back to refactor.
Name Mapping - Basic Mapping Criteria
https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/basic-mapping-criteria.html
Name Mapping Selectors:
https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/selectors.html#update-mapping-criteria-for-web-objects-only
The most effective stable mapping method I have found is to avoid the use of extended find and always base your mappings from the nearest unique parent object. In many cases this will require manual intervention. If your pages have many similarly named objects it's just going to take work to make it stable unfortunately,
- Organizing elements under their respective page objects to avoid cross-page conflicts.
- Refining Name Mapping properties to use stable identifiers like id, name, or meaningful attributes.
If your pages are well structured and objects named this isn't as much of a hassle. TestComplete does a pretty good job of assigning object properties useful for object identification. Work closely with your devs so your pages are 'testable' and have solid names for automation.
I am on the fence about 'Self Healing'. I turn it off. Some prefer to use it because a script will go ahead and run if the id can be changed during runtime to something that works.
The use of TestComplete's AI features can be a big help here as well. These will let you find objects visually instead of by code.
... If you find my posts helpful drop me a like! 👍 Be sure to mark or post the solution to help others out and/or to credit the one who helped you. 😎