Telerik blogs

 

Along with the Service Pack of RadControls for Silverlight Q2 we released an update of the free test automation solution, the WebAii Testing Framework. There are additions, fixes and improvements in all the components including the core WebAii, WebAii RadControls for Silverlight and ASP.NET AJAX. With this post I’d like to bring your attention to the latest addition to our Silverlight controls wrappers – the RadHtmlPlaceholder one.

As you probably know, the control itself is a pretty useful component part of the RadControls for Silverlight suite. RadHtmlPlaceholder allows you to host any HTML content in your Silverlight application configuring just a few properties. Check out the live demos for details.

The new WebAii Testing Framework 2009.2 812 update gives you not only access to the Silverlight object from the HTML host but also to the HTML content held by RadHtmlPlaceholder. We added a wrapper exposing a property that serves as a bridge to the HTML code. All the other code is hidden behind that property to make the test as simple as possible.

I’m sharing a sample test code (included as part of the product test samples), along with the video above showing the test execution. The live demo under test contains RadHtmlPlaceholder holding www.google.com as HTML content. The test performs a regular Google search and verifies the expected result page is loaded.

 

        [TestMethod]
        [Description("HtmlPlaceholder Html frame browser source test.")]
        public void HtmlFrameBrowserSourceTest()
        {
            // initialization part -- launches the browser, navigates to the live demo and gets the Silverlight application object this.LaunchInitialize("/Default.aspx#HtmlPlaceholder/FirstLook");

            // gets the Silverlight RadHtmlPlaceholder wrapper
            RadHtmlPlaceholder placeholder = app.Find.ByName<RadHtmlPlaceholder>("RadHtmlPlaceholder1");

            // gets its HTML frame browser instance to be able to search within 
 Browser htmlFrameBrowser = placeholder.HtmlFrameBrowser;
            htmlFrameBrowser.WaitUntilReady();
            htmlFrameBrowser.RefreshDomTree();

            // running google.com -- finds the search input text box from the search form
            HtmlForm searchForm = htmlFrameBrowser.Find.ByName<HtmlForm>("f");
            HtmlInputText searchInput = searchForm.Find.ByName<HtmlInputText>("q");

            // focuses the input and types some text
            Desktop.Mouse.Click(MouseClickType.LeftClick, searchInput.GetRectangle());
            Desktop.KeyBoard.TypeText("WebAii Testing Framework", 50);

            // submits the search query
            searchForm.Find.ByName<HtmlInputSubmit>("btnG").Click();

            // uses the updated frame to find and clicks on the first link from the results list
            HtmlDiv resultsDiv = ActiveBrowser.Frames[2].Find.ById<HtmlDiv>("res");
            resultsDiv.Find.ByTagIndex<HtmlAnchor>("a", 0).Click();

            Assert.IsTrue(htmlFrameBrowser.Url.StartsWith("http://www.telerik.com/"));
        }

 

Enjoy!

Konstantin Petkov, Telerik

 


Comments

Comments are disabled in preview mode.