it is bad programming but if you can't change it you should use hierarchy to locate the correct way.
Some examples. Don't search an element in deeper structure from main window. So if the parent of your textbox don't contains other textboxes. search the parent first. And than search the textbox from the parent element.
- Control 1
- Control 2
Window window = Application.GetWindow("windowname");
UIItem control1 = window.Get....
UIItem control2 = control1.Get....
TextBox box = control2.Get<TextBox>(SearchCritieria.ByControlType(ControlType.Edit));
if there are more TextBoxes try search by index. Or try using GetMultiple (only WPF, set using White.Core.UIItems.WPFUIItems; )
Here you get a List of Elements and you can use ,First(), .Last() or [index] to get the element.
In some cases you can also use the ClassName or other criteria.