WebAii UI Automation : Create Wrapper classes for custom user controls in Silverlight

6 posts, 0 answers
  1. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 21 Jul 2010 Link to this post

    Requirements

    RadControls version

     

    .NET version

    3.5

    Visual Studio version

    Visual studio 2008

    programming language

    C#

    browser support

    all browsers supported by RadControls


    WebAii UI Automation : Create Wrapper classes for custom user controls in Silverlight

    I have created a sample to demonstate how to create wrapper classes for custom user controls in silverlight.
    Wrapper class helps to reduce the writing codes to automate custom user controls.
    The full project sample is attached.

    If there is any question feel free to post it in this thread.

    Thanks
    Kiran
  2. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 23 Jul 2010 Link to this post

    Hi Kiran,

    Thanks a lot for your time and submission of the CodeLibrary project. I have some notes and updates you may find useful.

    First I'd like to add some functionality to the project in regards to the AutomationProperty capabilities of WebAii. The automation properties are useful to get access to the actual custom control properties.

    For example the Silverlight user control can expose a Text public property:

    public string Text
    {
        get
        {
            return this.txtUserName.Text;
        }
    }

    and the control wrapper can access it via an AutomationProperty like this:

    private static AutomationProperty TextProperty = new AutomationProperty("Text", typeof(string));
     
    /// <summary>
    /// Just a sample usage of automation properties.
    /// </summary>
    public string Text
    {
        get
        {
            // return this.SearchTextBox.Text;
            return (string)this.GetProperty(TextProperty);
        }
        set
        {
            this.SetProperty(TextProperty, value);
        }
    }

    I've also added a test to make sure I've not missed anything in the implementation:

    [TestMethod]
    [Description("A sample test method demonstrating the Text automation property usage.")]
    public void UserLookupTextTest()
    {
        LaunchApplication();
        UserLookup userLookup = CurrentApplication.Find.ByName<UserLookup>("UserLookupCtrl");
     
        userLookup.TypeText("WebAii");
        Assert.AreEqual("WebAii", userLookup.Text);
    }

    I hope this info helps!

    Another note is, we always recommend making the project independent from the exact assemblies version so that no matter which future build you install, you just rebuild the solution and proceed. This requires to update the SpecificVersion to "False" from the projects assembly references (ArtOfTest.Common, ArtOfTest.WebAii).

    In order to run the tests after upgrading that project with a new version, you may also need to change the config section a bit. It currently refers the ArtOfTest.WebAii with the exact version and instead you can remove the assembly details:
    <configSections>
      <section name="WebAii.Settings" type="ArtOfTest.WebAii.Core.SettingsConfigSectionHandler,ArtOfTest.WebAii"/>
    </configSections>

    As well as set the Copy Local property of the referenced assembly to True so that Visual Studio can get it from the output folder.

    I've attached an image to show the mentioned assembly settings (SpecificVersion, CopyLocal) along with the updated project.

    Kiran, I'd like to thank you once again for your community engagement. As a token of gratitude you will find your Telerik points updated shortly.

    Sincerely yours,
    Konstantin Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 23 Jul 2010 Link to this post

    Hi Petkov,

    Thanks a lot for your suggestions and feedback.

    Actually i needed to know the best practices when we write UI Tests.
    How can we make it more generic in such a way that even if the UI changes the changes in the Test should be minimal. (Wrapper is a good step for this)

    Also i am planning to create another code library sample which will demonstrate ChildWindow, MessageBox and Popup automation.
    This is because i lost a lot of time to make it work and similar issues are being repeatedly asked in the forums.
    So i think it will help others and also you guys to close the issues without spending much time.

    Thanks
    Kiran

  4. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 23 Jul 2010 Link to this post

    Hello Kiran,

    >>
    How can we make it more generic in such a way that even if the UI changes the changes in the Test should be minimal. (Wrapper is a good step for this)

    That is always an issue in terms of test automation. As you probably know we ship the RadControls Wrappers to always match the latest RadControls updates. This makes the WebAii Framework upgrade for our customers pretty straight forward as we wrap the changes internally.

    Actually that is another benefit of WebUI Test Studio compared to the framework. You can check this blog post for details on how our advanced test automation solution handles the UI changes making clients life easier.

    Let's move the discussion into the forums so that we don't spam this nice CodeLibrary thread. ;)

    Greetings,
    Konstantin Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Ohsha
    Ohsha avatar
    57 posts
    Member since:
    Mar 2012

    Posted 22 Mar 2012 Link to this post

    Hi, 

    The url for this blog post has gone. 
    Could you update it please? 
    Thanks

  6. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 22 Mar 2012 Link to this post

    Hello Ohsha,

    You can find that blog post here.

    Kind regards,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top