WebAii UI testingfreamework - How test in a correct way composite user control

2 posts, 0 answers
  1. Rolando
    Rolando avatar
    15 posts
    Member since:
    Nov 2011

    Posted 11 Dec 2011 Link to this post

    I am doing research about how to test our silverlight app in a correct way, and one question what I would like know is how we should test composite control (for example MyInventoryView.xaml is a view wich  contain a list of itemView.xaml using a ListBox)
    something like:
                            <xyz:ItemView  ...  />

    How I should get a list of these itemView objects?

    The easy way to get a control when we know the name and the type is 

    But what is the way to get when we are talking about specific usercontrol? (shall we add a reference from the project wich has the specific usercontrol??)

    Best Regards,

  2. Stoich
    Stoich avatar
    1 posts

    Posted 16 Dec 2011 Link to this post

    Hi Rolando,
    I'm not sure I correctly understand you question?

    You want to get all the ListBoxItems from a ListBox control? Here's a code sample that does that for the ListBox found this demo page:

    Manager.Settings.Web.EnableSilverlight = true;
        //Settings.Current.Web.EnableSilverlight = True
        // Launch a browser instance
        // The active browser
        SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
        ListBox lb = app.Find.ByAutomationId<ListBox>("cityList");
        int counter=1;
        foreach (ListBoxItem lbi in lb.Find.AllByType<ListBoxItem>())
            Log.WriteLine("ListBoxItem " + counter.ToString() +":"+ lbi.Text);

    This code will write the text of each ListBoxItem to the test log.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top