Tuesday, 3 June 2014

Control not found while spying with CUIT builder

This can be achieved by simply increasing the levels of object identification while recording

Suppose if there are more layers than 2, for example, in a WPF application, then it is possible to add more layers in the recordings. 

You will notice in the UIMap Designer tab (double click UIMap.uitest in the Solutions Explorer tab), that the depth of the controls, on the right side, is limited to layer that you are not trying to capture. If you try to Assert on "invisible" controls, there is a error message that the bottom of the Assert dialog "control not found". And after right clicking the Control on the "ui control map"..."Find Control"....it will never be found....again the layers of your project are not being seen by the recorder. Then change the setting the capture the appropriate layers of your project. Too many layers, too much memory. 

To fix, you will have to change the default settings in the core of your VS IDE. 

On your local PC, go to "..\\Microsoft Visual Studio 12.0\Common7\IDE". (for VS2013) Inside there is a file named "CodedUITestBuilder.exe.config". Open it in a text editor. Increase the value for the key of MaxLevelsForItemContainer to you project requirements. 

Example below: 

<!-- Use this to set the maximum level of search hierarchy for WPF and Windows Runtime Xaml controls having nested Item containers, 
when authoring or recording Coded UI tests. --> 
<add key="MaxLevelsForItemContainer" value="2"/> 

Happy coding :)