Getting List/Collection of the same type of control

Nov 23, 2012 at 4:28 PM

Hi,

Is there anything internally where I can get a collection of the element that i'm looking for. I have a few scenarios where I expect there to be more than one element on the page with the same ID as the scenario expects this to happen.

In this case, I expect multiple dropdowns. I'd like to add each dropdown that it finds matching the search criteria (each dropdown will have the same ID) to a List so I can iterate against the list to perform my actions.

Thanks

Nov 23, 2012 at 4:59 PM

I think I found part of the solution/workaround. I can call on my CUITe element:

.UnWrap().FindMatchingControls();

But I don't know how to convert the collection of UITestControls back to CUITe_HtmlComboBox objects so I can action against them.

Coordinator
Jan 17, 2013 at 8:24 AM

Hi ddoorn,

See this work item: http://cuite.codeplex.com/workitem/749

CUITe v1.5 already includes a GetChildren() method that can be used to retrieve a specific child control by its index.

 


Sample_CUITeTestProject\HtmlControlTests.cs also has sample code to convert an HtmlEdit control to a CUITe_HtmlEdit control as follows:

[TestMethod]
[WorkItem(589)]
public void HtmlEdit_Wrap_Succeeds()
{
    GoogleHomePage pgGHomePage = CUITe_BrowserWindow.Launch<GoogleHomePage>("http://www.google.com");
   
    HtmlEdit tmp = new HtmlEdit(pgGHomePage);
    tmp.SearchProperties.Add("Id", "lst-ib");

    CUITe_HtmlEdit txtEdit = new CUITe_HtmlEdit();
    txtEdit.WrapReady(tmp);
    txtEdit.SetText("Coded UI Test enhanced Framework");
    GoogleSearch pgSearch = CUITe_BrowserWindow.GetBrowserWindow<GoogleSearch>();
    pgSearch.Close();
}