title: Unable to identify WinEdit control in CodedUI test
body: <p>I'm trying to hand-code a simple CodedUI test in VS 2013. I have a simple windows forms app with three TextBoxes (txtA, txtB and txtC) and a Button (btnAdd) on a form. On clicking the button, the app will add the numbers entered in txtA and txtB and show the result in txtC as below:</p>
  
  <pre><code>        var a = Convert.ToInt32(txtA.Text);
          var b = Convert.ToInt32(txtB.Text);
          txtC.Text = (a + b).ToString();
  </code></pre>
  
  <p>And my coded UI test is as follows :</p>
  
  <pre><code>[TestMethod]
      public void CodedUITestMethod1()
      {
          ApplicationUnderTest app = ApplicationUnderTest.Launch(@"C:\Users\Dileep\Documents\Visual Studio 2013\Projects\CodedUIDemo\SimpleCalculator\bin\Debug\SimpleCalculator.exe");
  
          WinEdit txtA = new WinEdit(app);
          WinEdit txtB = new WinEdit(app);
          WinEdit txtC = new WinEdit(app);
          WinButton btnAdd = new WinButton(app);
  
          txtA.SearchProperties.Add(WinEdit.PropertyNames.Name, "txtA");
          txtB.SearchProperties.Add(WinEdit.PropertyNames.Name, "txtB");
          txtC.SearchProperties.Add(WinEdit.PropertyNames.Name, "txtC");
          btnAdd.SearchProperties.Add(WinButton.PropertyNames.Name, "btnAdd");
  
          txtA.Text = "50";
          txtB.Text = "50";
          Mouse.Click(btnAdd);
          var result = txtC.GetProperty("Text").ToString();
          Assert.AreEqual("100", result);
      }
  </code></pre>
  
  <p>When I run the test, it launches the app, waits for a while and then fails with the following error :</p>
  
  <p>Result Message: </p>
  
  <blockquote>
    <p>Test method SemiAuto.CodedUITest1.CodedUITestMethod1 threw exception: 
    Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details: 
    TechnologyName:  'MSAA'
    ControlType:  'Edit'
    Name:  'txtA'
     ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
    Result StackTrace:<br>
    at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object&amp; pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
       at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException, Boolean resetSkipStep)
       at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth, Boolean resetSkipStep)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32&amp; timeLeft)
     --- End of inner exception stack trace ---
        at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapControlNotFoundException(COMException ex, IPlaybackContext context)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, IPlaybackContext context)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String queryId)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32&amp; timeLeft)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindControlIfNecessary()
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyPrivate(String propertyName, Object value)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.&lt;>c__DisplayClass3e.b__3d()
       at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetProperty(String propertyName, Object value)
       at Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinEdit.set_Text(String value)
       at SemiAuto.CodedUITest1.CodedUITestMethod1() in c:\Users\Dileep\Documents\Visual Studio 2013\Projects\CodedUIDemo\SemiAuto\CodedUITest1.cs:line 41</p>
  </blockquote>
  
  <p>I tried using the <code>SetProperty</code> method but that also doesn't work. </p>
  
  <p>If I run the recorder and generate code, it wraps controls in a WinWindow control. For example, the <code>txtA</code> <code>TextBox</code> control is wrapped like this in <code>UIMap</code> class :</p>
  
  <pre><code> public class UITxtAWindow : WinWindow
  {
      public UITxtAWindow(UITestControl searchLimitContainer) : 
              base(searchLimitContainer)
      {
          this.SearchProperties[WinWindow.PropertyNames.ControlName] = "txtA";
          this.WindowTitles.Add("Form1");
      }
  
      public WinEdit UITxtAEdit
      {
          get
          {
              if ((this.mUITxtAEdit == null))
              {
                  this.mUITxtAEdit = new WinEdit(this);
                  this.mUITxtAEdit.WindowTitles.Add("Form1");
              }
              return this.mUITxtAEdit;
          }
      }
      private WinEdit mUITxtAEdit;
  }
  </code></pre>
  
  <p>I don't understand why it is done like this. Can someone explain this,please ?</p>
  
  <p>Thanks
  Dileep Krishnan</p>