Forum Discussion
tristaanogre
14 years agoEsteemed Contributor
Are you using the Name property in the find? I, personally, would avoid that. I would also avoid, if you're looking for a particular object, using the index as a reference as that is not always a static value (sometimes the same object may return under a different index depending upon how the application under test renders and displays them).
What you should do in your find call is choose properties that, the combination of which, will locate and return the particular object. For example, you know that the class name is "TextBox" and you are looking for a particular one with a particular caption, I'm assuming.
so, what I would do is the following:
This will return the first child object off the application with a class of TextBox, a caption of 1, and will search down a depth of 10 items.
The Name property is unreliable for a search using Find because the Name property can contain variable values, in this case, the index, which are unreliable in returning what you want.
What you should do in your find call is choose properties that, the combination of which, will locate and return the particular object. For example, you know that the class name is "TextBox" and you are looking for a particular one with a particular caption, I'm assuming.
so, what I would do is the following:
var MyObject = MyApp.FindChild(["WndClass", "WndCaption"], ["TextBox", "1"], 10)
This will return the first child object off the application with a class of TextBox, a caption of 1, and will search down a depth of 10 items.
The Name property is unreliable for a search using Find because the Name property can contain variable values, in this case, the index, which are unreliable in returning what you want.