title: How do you determine (WinForms) control type in UITestControl?
body: <p>I'm trying to make custom properties for controls available in Coded UI Tests and every example I've found is totally useless.</p>
  
  <p>For instance: <a href="http://msdn.microsoft.com/en-us/library/hh552522.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/hh552522.aspx</a></p>
  
  <pre><code>public override int GetControlSupportLevel(UITestControl uiTestControl)
  {
      // For MSAA, check the control type
      if (string.Equals(uiTestControl.TechnologyName, "MSAA",
      StringComparison.OrdinalIgnoreCase) &amp;&amp;
      (uiTestControl.ControlType == "Chart"||uiTestControl.ControlType == "Text"))
      {
          return (int)ControlSupport.ControlSpecificSupport;
      }
  
      // This is not my control, so return NoSupport
      return (int)ControlSupport.NoSupport;
  }
  
  // Get the property value by parsing the accessible description
  public override object GetPropertyValue(UITestControl uiTestControl, string propertyName)
  {
      if (String.Equals(propertyName, "State", StringComparison.OrdinalIgnoreCase))
      {
          object[] native = uiTestControl.NativeElement as object[];
          IAccessible acc = native[0] as IAccessible;
  
          string[] descriptionTokens = acc.accDescription.Split(new char[] { ';' });
          return descriptionTokens[1];
      }
  
      // this is not my control
      throw new NotSupportedException();
  }
  </code></pre>
  
  <p>This code is entirely worthless if you have 2 different controls that are "Text" controls - there is no way to determine which type of text control it is. The "ControlType" property is very misleading because it does not return the Type of the control as its name suggests. It's more like a control category. How can you determine what the control actually is?</p>