WebAii Testing Framework: From HTML to XAML and Back -- RadHtmlPlaceholder

Posted by: the telerik blogs, on 27 Aug 2009 | View original | Bookmarked: 0 time(s)

 

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 Id 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.

Im 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

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: ASP.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 2180 | Hits: 5

Similar Posts

  • Simple jQuery Delete Link For ASP.NET MVC more
  • HTML Stripping Challenge more
  • What's up with unit testing? part I more
  • An Arbitrary Cycle Method For ASP.NET MVC more
  • Silverlight Browser Integration aka HTML Bridge more
  • Blogging from Tech Ed 2006 - Brian Button on how to write frameworks - level 300 more
  • Automated testing with .Net - an overview - level 200 more
  • Using a Base Class to Fiddle with a Page's Rendered Output more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD