Accessing RadControls for ASP.NET Ajax items with WatiN(by using only the html elements)

Posted by: the telerik blogs, on 18 Oct 2008 | View original | Bookmarked: 0 time(s)

Are you curious how to deal with the complicated rendering of RadControls and WatiN? If so, I will shed some light on this.

Here is an example how to print the text of the specific node of RadTreeView and how to expand it:

[STAThread]
static void Main(string[] args)
{
IE ie = new IE("http://demos.telerik.com/aspnet/prometheus/TreeView/Examples/Programming/DataBinding/DefaultCS.aspx");
Element ulElement = ie.Element("UL", Find.ByClass("rtUL rtLines"));
Element firstLiElement = ulElement.DomContainer.Element("LI", Find.ByIndex(1));
Span textSpanElement = (Span) firstLiElement.DomContainer.Div(Find.ByClass("rtTop")).DomContainer.Span(Find.ByClass("rtIn"));
Console.WriteLine(textSpanElement.Text);
Span plusSpanElement = (Span)textSpanElement.PreviousSibling;
plusSpanElement.Click();
}

 

Yet another example how to click on a child item of RadMenu(you have to open its parent first):

 

[STAThread]
static void Main(string[] args)
{
IE ie = new IE("http://demos.telerik.com/aspnet/prometheus/Menu/Examples/Programming/AddRemoveDisableItems/DefaultCS.aspx");
Element item1LiElement = ie.Element("li", Find.ByClass("rmItem rmFirst"));
item1LiElement.FireEvent("onmouseover");
ie.Span(Find.ByText("Text File")).WaitUntilExists();
Span childMenuItem = ie.Span(Find.ByText("XML File"));
childMenuItem.Click();
}

 

 

[STAThread]
static void Main(string[] args)
{
IE ie = new IE("http://elena/telerik.web.examples/Scheduler/Examples/Default/DefaultCS.aspx");
Element scrollContent = ie.Element("div", Find.ByClass("rsContent rsScrollingContent rsDayView"));
Element contentTable = scrollContent.DomContainer.Element(Find.ByClass("rsContentTable"));
Element appDiv = contentTable.DomContainer.Element("RadScheduler1_10_0");
Console.WriteLine(appDiv.Title);
appDiv.DoubleClick();
}

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: Ajax | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1911 | Hits: 6

Similar Posts

  • Data-binding Telerik CoverFlow for Silverlight + some Routed Commands goodness more
  • WebAii Testing Framework: From HTML to XAML and Back -- RadHtmlPlaceholder more
  • HTML Stripping Challenge more
  • TreeView in a ComboBox dropdown using RadControls for Silverlight more
  • AJAX >> Using AJAX to load a usercontrol that has refers to a custom css file more
  • Silverlight Browser Integration aka HTML Bridge more
  • Data bound fields for Ajax forms more
  • The Ajax Papers: Part II more
  • Ajax.NET Professional 6.6.2.2 with new Converters more
  • Less waiting on AJAX 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