Ask a Question

Choosing between findchild and namemapping


Choosing between findchild and namemapping

Not sure when it is appropriate to use findchild and when namemapping?

What to use( findchild or namemapping) when we see the desired object is at very deep level i.e the hierarchy is very long ?
Community Hero

RE: Choosing between findchild and namemapping

We have a phrase in US culture:

"Six one way, half a dozen the other" meaning that there is very little difference between the two choices.

To be honest, I don't think there really is much advantage one over the other.  Using FindChild requires you to write in code the specifics of the object you're searching for and have that object resolved at run time.  Using NameMapping allows you to predefine it ahead of time and, using Aliases, "telescope" the object down to something easily referenced.  Overhead different between the two, as far as I know, is negligible.

Personally, I use FindChild when the parameters of the object may not be known ahead of time and are dependant upon other items in the application so the object is VERY dynamic.  NameMapping I use for objects that are much more static and won't change from test case to test case.  But there are ways of overcoming this in both methods so I can't necessarily say my way is THE right way to do things.

Not much help, I know, but that's the best I can do.

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

RE: Choosing between findchild and namemapping

Hi Krushna,

If your goal is to shorten expressions for addressing objects, use the NameMapping feature. This approach lets you define the object in advance and allows you to change the object hierarchy by excluding intermediate objects from the syntax. I recommend that you read in the online documentation.

The FindChild method is typically used for the dynamical search for the object. Note that the FindChild speed depends on the Depth parameter. So, I recommend that you call FindChild belonging to the nearest known parent of the target object. For more information on using this method, please refer to

I’m not a member of the SmartBear Support Team, I’m just helping users in this community. Any views or opinions expressed do not necessarily represent those of SmartBear Software.
Showing results for 
Search instead for 
Did you mean: