Forum Discussion
I would not use the "Name" property of an object to find the object. Basically, if you're looking for something via the Name, TestComplete just goes ahead and bypasses all find functionality and attempts to search using the Name as per the Object Browser. I'd recommend enhancing your function to actually take in the arrays of properties and values instead of just "name" to get more specific and targeted searches.
tristaanogre wrote:I would not use the "Name" property of an object to find the object. Basically, if you're looking for something via the Name, TestComplete just goes ahead and bypasses all find functionality and attempts to search using the Name as per the Object Browser. I'd recommend enhancing your function to actually take in the arrays of properties and values instead of just "name" to get more specific and targeted searches.
PropNames = Array("Name", "Index", "Visible") 'All values present PropValues = Array(VBobj, Idx, True) Set P = (Parent)
I almost always use Name (Partial of the vbobject name), Parent and Index.
The VBObject name of the child has to be partial as at compile the object name is often suffixed with a number, for example the Object is called CtlBox becomes CtlBox_12 but the index stays the same.... that is unless a dev ads a new control further up in the pecking order and the controls are re-indexed but that's a very quick change in my script code to fix it.
I can't use WndCaption in a lot of situations as most have been written as custom controls in containers due to exceeding the control limit of VB6 and don't have a WndCaption. WndClass is shared by lots of objects and some may have the same index across the whole screen but unique within their own containers.
I'm starting to think that I should resign myself to the long object searches.
Although to toot my own horn, I do manage to run around 160 Units covering 21 tests in roughly 40 minutes compared to my predecessor whom manged 5 scripts covering 1 test in over an hour.
- tristaanogre7 years agoEsteemed Contributor
You don't have to use WndCaption and WndClass only... you can pass in any set of properties and corresponding values to find the component. I've found this to be a common mistake among newer users that they look at only the very basic properties and don't look deeper.
So, look beyond just using "Name". Add other properties to narrow things down to the specific component you're looking for. INclude things like "Caption" or perhaps text content, label, ObjectIdentifier, etc. The more directed your Find, the easier it is for TestComplete to find your component.