Using the find method(s) ...not sure what I am doing wrong
- 6 years ago
The "Name" property is not what you think it is. It's actually, if you look at it in the Object Spy the full name of "TextBox('loginstart_username')". It's not a recommended property to find for.
What you probably want to do, if you're going to use "Find", is to actually pass in arrays of properties and values. So, in your example, you would want something like
pageRoot.Find(['ObjectType', 'ObjectIdentifier'],['TextBox', 'loginstart_username'], 9999, true)
Now... that all said.... what you're trying to do, as I see it, is remove all those "Panel.Panel.Panel" references...and you say that you're doing so to obfuscate NameMapping...
...you probably aren't using the Aliases right in NameMapping then.
Basically, if I have an object that NameMapping might map likeNameMapping.Sys.Browser.page.panel.panel.panel.table.cell.panel.loginTextBox
The Alias, when you first map it MIGHT look like this.
Aliases.Browser.page.panel.panel.panel.table.cell.panel.loginTextBox
Well, if you edit your Alias, you can drag loginTextBox to be a direct chiild of the page and then "Exclude" all the intermediary stuff. So, your NameMapping.Sys will still look the same (which is OK... and necessary) but your Alias will look like
Aliases.Browser.page.loginTextBox.
Read up on NameMapping at https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/about.html#aliases-and-mapped-objects
While Find WILL work.... you end up with an overhead that is unnecessary. Find, actually, consumes more time and processor time than if you're using the NameMapping repository for object identification. And, with NameMapping, there's less code to maintain and keep track of. Check it out.