You can record the action you want to test and then customize the auto-generated code inside the UIMap.Designer.cs
file to select the control you need. For each control you use when you record your test the CodedUi Test Builder
creates a new class inside this file. If your controls are similar (eg. control1, control2...) assign the parameter name to the Search Properties
of this control:
public class UIItemWindow : WinWindow
{
public UIItemWindow()
{
#region Search Criteria
//Here assign the paramter to the search properties of the control
this.SearchProperties[WinWindow.PropertyNames.Name] = parameterName;
#endregion
}
#region Properties
public UIItemWindow1 UIItemWindow1
{
get
{
if ((this.mUIItemWindow1 == null))
{
this.mUIItemWindow1 = new UIItemWindow1(this);
}
return this.mUIItemWindow1;
}
}
#endregion
#region Fields
private UIItemWindow1 mUIItemWindow1;
#endregion
}
To see how you can pass parameters to the CodedUI test check these links: