Q:

Why is Coded UI Module failing to see UI Control Elements showing up in Internet Explorer browser?

Our Automated UI test code needs to search and find the link that contains the "p" html element with text called Customers. Finally, we need to automated uit test code to click on the aforementioned link.
<div data-bind="foreachRibbonItem: items">
 blah blah
 blah blah blah
<a class="btn txt-color-white" href="#" data-bind="click: content,      tooltip: {title : description, placement: 'bottom' }, keyTipsGroup : {         parentGroup: ribbonTabKeyTip, group: text }" data-original-title="" title="">
 <span class="txt-color-blueDark">
 <p data-bind="html: text">Customers</p>
  </a>
 blah blah
 blah blah blah
 </div>

The following is the C# code within my Unit Test Module that uses Microsoft Coded UI technology:
             url = new Uri("http://localhost:2816/");
             BrowserWindow brwsWin = BrowserWindow.Launch(url);
             brwsWin.Maximized = true;
             brwsWin.WaitForControlReady();
             UITestControl doc = brwsWin.CurrentDocumentWindow;
             HtmlControl control = new HtmlControl(doc);

            // Our application has a Rich User Interface with a lot of
            // UI controls so we have a quasi-placeholder UI div element          
             // associated with a class called "loading-screen" which just shows up
             // temporarily in the webpage, but disappears after all the visible UI
             // dev elements are loaded up.
             control.SearchProperties[HtmlControl.PropertyNames.ClassName] = "loading-screen";

            UITestControlCollection collection = control.FindMatchingControls();

             foreach (UITestControl loadScreen in collection)
            {
                  loadScreen.WaitForControlNotExist();
            }
            // The following Removes the "loading-screen" ClassName from our
             // search criteria
              control.SearchProperties.Remove(HtmlControl.PropertyNames.ClassName);

             // Let's just reinstantiate the control HtmlControl UI Element.
                       control = new HtmlControl(doc);
             // Now I'm just adding "div" tagname to the search criteria.
               control.SearchProperties[HtmlControl.PropertyNames.TagName] = "div";

             foreach (HtmlControl div in secondCollection)
            {
                div.WaitForControlExist();

                     div.SearchProperties[HtmlControl.PropertyNames.ClassName] = "btn txt-color-white";
                UITestControlCollection thirdCollection =      div.FindMatchingControls();
                foreach (UITestControl aLink in thirdCollection)
                {
                    //cast the item to HtmlHyperlink type
                     HtmlHyperlink mylink = (HtmlHyperlink)aLink;

                     HtmlControl paraFinder = new HtmlControl(mylink);

                          paraFinder.SearchProperties[HtmlControl.PropertyNames.TagName] = "p";
                      paraFinder.SearchProperties[HtmlControl.PropertyNames.InnerText] = "Customers";

                     UITestControlCollection fourthCollection =     paraFinder.FindMatchingControls();

                    if (fourthCollection.Capacity == 1)
                     {
                         Mouse.Click(mylink);
                     }
                  }

             }

The problem with the aforementioned code is that it fails to pick up any of the UI Control Elements when the code runs.
Could someone please help me determine what is Wrong?
My hunch is that it's probably something wrong with the way how I instantiate the HtmlControl , and how the said HtmlControl is associated with the "Website Under Test"
           url = new Uri("http://localhost:2816/");
            BrowserWindow brwsWin = BrowserWindow.Launch(url);
            brwsWin.Maximized = true;
             brwsWin.WaitForControlReady();
             UITestControl doc = brwsWin.CurrentDocumentWindow;
            HtmlControl control = new HtmlControl(doc);

Could someone please point out what is wrong with the code above?

A:

An easier way to get your link:  
public HtmlHyperlink link()
{
    HtmlControl paragraph = new HtmlControl(brwsWin);
    paragraph.SearchProperties["InnerText"] = "Customers";
    HtmlHyperlink target = (HtmlHyperlink)paragraph.GetParent();
    return target;
}

So that you can now simply Mouse.Click(link());
I always like to use the BrowserWindow object itself as the parent, but by definition it shouldn't cause any problems for you to use the doc object.
To improve speed, it helps to add identifying tags to your HTML elements, like ID or Name, that are unique to the element in question.  I've found that the Coded-UI engine can search that quicker than using the InnerText property.  Another hint would be to filter on the parent objects at an even higher level so the tool can find higher level elements first and not have to search the whole page for "customers".  For example, your link in the tree:
<body>
    <div id='div1'>
        <div id='div2'>
            <div id='div3'>
                <a id='customerLink'>Customers</a>
            </div>
        </div>
    </div>
<body>

would easily be found by specifying each of the parent DIV elements.
public HtmlDiv div1()
{
    HtmlDiv div = new HtmlDiv(brwsWin);
    div.SearchProperties["ID"] = "div1";
    return div;
}

public HtmlDiv div2()
{
    HtmlDiv div = new HtmlDiv(div1);
    div.SearchProperties["id"] = "div2";
    return div;
}

Do that for each of the parents, specifying the div right above it as the parent object when instantiating it (like we do with brwsWin above), then on the link:
public HtmlHyperlink link()
{
    HtmlHyperlink target = new HtmlHyperlink(div3);
    target.SearchProperties["id"] = "customerLink";
    return target;
}

