Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / WPF

Automated Testing in Silverlight

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
6 Apr 2009CPOL2 min read 42.2K   772   15  
Simulate user interactions in a Silverlight application to create automated tests
using System;
using System.Net;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace SilverlightSampleApp.ScriptEntryPoint
{
    [ScriptableType]
    public class MainPageEntryPoint
    {
        public SilverlightSampleApp.Page MainPage;
        public ElementAccessor elementAccessor;

        public SideView_EntryPoint SideView;
        public ScrollView_EntryPoint ScrollView;

        public MainPageEntryPoint(SilverlightSampleApp.Page mainPage)
        {
            MainPage = mainPage;
            elementAccessor = new ElementAccessor(this, MainPage.FindName);
            SideView        = new SideView_EntryPoint(this);
            ScrollView      = new ScrollView_EntryPoint(this);
        }

        public ElementAccessor ElementAccessor()
        {
            return elementAccessor;
        }
    }



    [ScriptableType]
    public class SideView_EntryPoint
    {
        public SilverlightSampleApp.SideView SideView;
        public MainPageEntryPoint Parent;
        public ElementAccessor elementAccessor;

        public SideView_EntryPoint(MainPageEntryPoint parent)
        {
            SideView = parent.MainPage.theSideView;
            elementAccessor = new ElementAccessor(parent, SideView.FindName);
            HtmlPage.RegisterScriptableObject("SideView_EntryPoint", this);
        }

        public ElementAccessor ElementAccessor()
        {
            return elementAccessor;
        }
    }


    [ScriptableType]
    public class ScrollView_EntryPoint
    {
        public SilverlightSampleApp.ScrollView ScrollView;
        public MainPageEntryPoint Parent;
        public ElementAccessor elementAccessor;

        public ScrollView_EntryPoint(MainPageEntryPoint parent)
        {
            ScrollView = parent.MainPage.theScrollView;
            elementAccessor = new ElementAccessor(parent, ScrollView.FindName);
            HtmlPage.RegisterScriptableObject("ScrollView_EntryPoint", this);
        }

        public ElementAccessor ElementAccessor()
        {
            return elementAccessor;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Tester / Quality Assurance
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions