I have to test an application that change control/widget indexes everytime it is maximized/minimized/run. This is pretty annoying because I record a test, and if I close and reopen/minimize the application and run the test I previously recorded on it, the test won´t find some of the controls. There are some controls that doesn´t can be found by name, and this are the ones that I have problem with, things like:
p1.Window('TdxBarSubMenuControl', '', 3).Click(55, 15);
(did you notice the '3', in the WIndow call?) are giving me this problem.
Next time I run the application and run the test on it, this index could be 1, 2, or 3, and app won´t find the control, though it exists (but with another index).
I have tried to use low level events but it is not very reliable. Could anybody tell me how could I test this? should I make the app opened to let me find this controls by a property that really identify it?, any tip is wellcomed.
1) Least reliable, manually edit your recorded scripts to use -1 for the index parameter. This will basically, then, grab the FIRST instance of that window object. It's not very reliable because the first instance is not always the correct instance.
2) Next most reliable. Using the Object Mapping feature within the project properties, try mapping your custom controls to known classes of controls. This might allow you to reference the object by it's name. Not the best because that object mapping makes assumptions about the objects that may or may not be true.
3) Most reliable. Read up on the "FindChild" method of TestComplete. Using that method, you can find specific child objects based upon a set of parameters. Assuming each instance of TdxBarSubMenuControl has something unique about it distinguishing it from the others, you should be able to use "FindChild" to return an instance of your control and utilize that.
Automated Testing Evangelists
Definition expert - noun - Unknown drip under pressure
In addition to Robert's suggestions, you can use the Name Mapping feature to identify the problematic controls by one or more properties other than Index. Please see the "Name Mapping" help topic for more information.