How to create dictionaries to add UI Controls

Author: Alfonso Alarcón

In Coded UI projects of visual Studio (Enterprise, Ultimate or Premium versions) control data (properties and values)  on the different functionalities are saved in structures named UI Controls. Even though other possibilities are possible the UI Controls can be stored in dictionaries to be invoked in functional methods. The important point is to create a dictionary for each type of control. Therefore, it can be a dictionary for: ComboBox, MenuBar, TableGrid, WinButton or WinEdit but the list can be more extends depending of the application. The “Key” of the dictionary is a constant string and the “Value” is the type of the UI Control.

All types of UI Controls are inheritance of the class UITestControl. Therefore, it is possible to create the dictionaries with this class but if you need specific methods of a particular UI Control you must work with its class. For example, in the case of combo boxes, you need to work with the specific methods of the class WinComboBox. In this dictionary all UI Controls are stored in a dictionary named ComboBoxDict inside the method UiTestComboBox():

public static class UIDict
{
	public static Dictionary<string, WinEdit> UiDictA()
	{
		UIMap uiMap = new UIMap();
		Dictionary<string, WinEdit> winEditDict = new Dictionary<string, WinEdit>();
		winEditDict.Add("A",uiMap.UIaWinEdit);            
		return winEditDict;        
	}
}

More information related with this post in:

https://msdn.microsoft.com/es-es/library/xfhwa508(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.uitestcontrol.aspx

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s