Adding all of the controls on a page to the UIMap - be careful!

When you create a coded UI test using Visual Studio 2010, the test only adds the controls you recorded or created assertions against; after all, why keep track of controls that your test will never use?  While that seems like a pretty straight forward assumption, in use, customers at times wish they could just press a button and add all of the controls on a page to the UI Map.

While it may not be as simple as pressing a button, Mathew Aniyan created some code that would allow you to do just that and he posted it on his BLOG here

This code should be a test method that you can run when you need to generate the UI Map file.  It's difficult trying to run this standalone (console app or Win Forms app) as there are certain objects that do not work well outside of the testing environment, specifically the BrowserWindow object.  Also, be sure you really need this.  I tried this on a simple web page and it generated a UI Map file of over 20,000 lines of XML code.  Not only did it take a long time to create the UI Map file, (the function that populates the map, GetAllChildren is recursive), I can't imagine what the performance of your test will be once you do this for multiple pages on a complicated site.