This is a common question that rises in the mind of every test developer.
The answer resides in the resilient playback support of the Coded UI Test Record and Playback Engine. The Record and Playback Engine recognizes controls on the user interface by its search properties. Several search properties may perhaps alter over phase. Record and Playback engine makes use of a Smart Match algorithm to identify windows/controls if they cannot be sited using the exact properties. The smart match algorithm exercise heuristics and try to locate the window/control using variations on the search properties. This is what happens when the Playback is able find the window or control even after one or more search properties have changed. The Record and Playback Engine utilize this algorithm and identifies the window and/or control...
You can dodge this behavior by manipulating when Smart Match should be applied. By default Smart Match is applied for Top Level Windows and all controls. You can turn off Smart match in cases where you would like only exact matches by means of the following code snippet:
Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None;
The default setting (Smart match top level windows and controls) is most favorable for a resilient coded UI test. However occasionally it may lead to false positives and then you will have to adjust this setting.
Richard Mueller edited Revision 7. Comment: Removed tags "Microsoft Visual Studio 2010" and "MS", added tag "See Also", changed tag "VS 2010" to "Visual Studio 2010"
Richard Mueller edited Revision 6. Comment: Remove blank headings in HTML to fix TOC
Ed Price - MSFT edited Revision 5. Comment: Updated headers to H1
Ed Price - MSFT edited Revision 3. Comment: Title guidelines and tags. Some formatting. The title didn't have the technology/product in it.
TejasJ edited Revision 2. Comment: Added links
TejasJ edited Original. Comment: Justify