There is about a month left to the major Q3 release and the free Web Automation Framework has been steadily evolving. We have just released an important update I highly recommend it to everyone who is interested in the easy test automation for both ASP.NET AJAX and Silverlight based applications with or without RadControls on the board.

The list of release notes is quite long including updates to all the components – the WebAii core framework, the product installer, WebAii RadControls for ASP.NET AJAX and Silverlight control wrappers. There are significant improvements especially in the Silverlight automation. Here I’d like to highlight one of the newly added features – support for extended RadControls for Silverlight.

 

The problem

There are many cases when customers extend the Microsoft or Telerik Silverlight components – you can either add or change control functionality as per your needs. In Silverlight though, this results in a new element type in the visual tree. Until now the WebAii framework failed to identify the base control. In other words, customers were unable to use the RadControls wrappers over the inherited controls out-of-the-box.

 

The solution

WebAii v2.0.4 adds a new feature – control mappings support and it has been already implemented by the RadControls wrappers. Everyone who needs our wrapper controls in extended components scenario now can override the respective control mappings in order to match the tested control type. You just need a few lines of code, see below.

 

Example

In one of my tests I’m extending one of the newly added controls to the RadControls suite – RadDropDownButton.

 using Telerik.Windows.Controls;

    public class ExtendedDropDownButton : RadDropDownButton
    { 
        // add your implementation here
    }

 

In my sample demo in XAML I’m defining several instances like this:

<extended:ExtendedDropDownButton x:Name="DaySelector" ../>

 

So I have a demo to test with the help of the WebAii RadDropDownButton wrapper. Here is my initial WebAii test running this live demo. I’m checking various settings of the drop down here:

        [TestMethod]
        [Description("DropDownButton settings test.")]
        public void DropDownSettingsTest()
        {
            LaunchInitialize("/TestPage.aspx#Buttons/FirstLook");

            RadDropDownButton daySelector = app.Find.ByName<RadDropDownButton>("DaySelector");
            Assert.IsFalse(daySelector.IsPopupOpen);

            Assert.AreEqual<double>(54, daySelector.Width);
            Assert.AreEqual<double>(22, daySelector.Height);

            Assert.IsNotNull(daySelector.AutoOpenDelay);
            Assert.AreEqual(0, daySelector.AutoOpenDelay.Milliseconds);
            Assert.AreEqual(0, daySelector.AutoOpenDelay.Seconds);

            Assert.IsTrue(daySelector.CloseOnEscape);
            Assert.IsTrue(daySelector.HasDropDownContent);
            Assert.IsTrue(daySelector.DropDownIndicatorVisibility == Visibility.Visible);
        }

 

To override the DropDownButton control mappings, first I need the control mapping key. We’ve gathered all the keys in a static class namely RadControlMappingKeys. I’m initializing my MappingsCollection, setting my new value there and registering the mappings via the static Manager.RegisterMappingsOverride method. I call the below method as a part of the initialization of all my tests for that sample demo:

 private void RegisterExtendedDropDownMappingsCollection()
        {
            MappingsCollection myCustomList = new MappingsCollection();
            myCustomList.Add(RadControlMappingKeys.DropDownButtonKey, "ExtendedDropDownButton");
            Manager.RegisterMappingsOverride(myCustomList, typeof(RadDropDownButton));
        }

 

And that’s all, as easy as possible.

Needless to say, WebUI Test Studio v2.0 will not require any code to update the WebAii control mappings if needed. Instead, you will get the appropriate UI listing the registered mappings that you can easily update.

I hope this helps!

-Konstantin


Related Posts

Comments

Comments are disabled in preview mode.