This is a migrated thread and some comments may be shown as answers.
WebAii UI testingfreamework - How test in a correct way composite user control
1 Answer 27 Views
This is a migrated thread and some comments may be shown as answers.
Rolando
Top achievements
Rank 1
Rolando asked on 12 Dec 2011, 03:51 AM
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.


1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 16 Dec 2011, 01:56 PM
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.
Asked by
Rolando
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or