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

    Hi,
    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:
    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <xyz:ItemView  ...  />
                        </DataTemplate>
                    </ListBox.ItemTemplate>


    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 
    itemViewSilverlightApp.Find.ByName<DataGrid>("myName");

    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,
    Rolando.


  2. Stoich
    Admin
    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:
    http://demos.telerik.com/silverlight/#CoverFlow/Integration

    Manager.Settings.Web.EnableSilverlight = true;
        //Settings.Current.Web.EnableSilverlight = True
        // Launch a browser instance
        Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
     
        // The active browser
        ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/#CoverFlow/Integration");
     
        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);
            counter++;
        }

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

    Greetings,
    Stoich
    the Telerik team

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