Random Musings

May 3, 2009

How to use ASP.NET Ajax RadComboBox with WatiN

Filed under: telerik,watin — haditeo @ 5:24 pm
Tags: ,

I am curious in how to select a valid value from the Telerik ASP.NET Ajax RadComboBox with WatiN.

First of all i googled around its forum and found this forum post. I didn’t look carefully as it was only applied to ASP.NET RadComboBox and ASP.NET Ajax RadComboBox

No wonder, after i blindly used it without modifying it, the DOM element cannot be found. Here my IE Developer Toolbar with IE 8 came to rescue

Take a look at the (a) tag inside this screenshot. In the ASP.NET RadComboBox, it was still using (image) tag

combobox1

Take a look at the (li) tag for the items in the combo box. Previously it was using (div) tag

combobox21

Here is the code snippet:

  // currently my RadComboBox client-id name is ddlTopic. 
  // please substitute your proper combobox name appended by "_Arrow" 
  Link radComboBoxDropDownImage = ie.Link(Find.ById("ddlTopic_Arrow")); 
  radComboBoxDropDownImage.Click(); 
 	 
  // my RadComboBox client-id name is ddlTopic 
  // please substitute with your proper combobox name appended by "_DropDown" 
  Div divTopic = ie.Div(Find.ById("ddlTopic_DropDown")); 
 	 
  ElementCollection elColl = divTopic.ElementsWithTag("li"); 
 	 
  // here i would like to select the 4th option inside the combo-box 
  // the dropdownlist option index is started with 0  
  elColl[3].FireEvent("onmouseover"); 
  elColl[3].Click();  
Advertisements

2 Comments »

  1. I have to test with more than one dropdowns having same class.Can u please help me how to do that… For eg)we have three dropdowns having same class name “ddlTopic_DropDown”. In that case,how will you trigger the each dropdown.

    Thanks in Advance.

    Comment by Karthik — November 6, 2009 @ 5:03 pm | Reply

  2. Thank you very much. Solution works 100%.

    Comment by lukas — December 4, 2009 @ 8:49 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: