Contact Sales: +1-888-365-2779

How to select RadComboBox item with WatiN

Thursday, May 29, 2008 by Telerik Automated Testing Tools | Comments 4

Firstly let me introduce myself. My name is Elena Tosheva and I’m a QA officer here at Telerik. I have been working here since the end of 2004 year, but it is the first time I’m blogging.

I’m responsible for testing ASP.NET team 3 controls (RadComboBox, RadPanelBar, RadTabStrip, RadTreeView, RadMenu, RadToolBar and RadScheduler).

 

As you may already know , we use Selenium for integration testing together with the NUnit and JsUnit tests. Selenium is the best tool which fits our needs for the present.

Here is a blog post provided by Falafel how to select RadComboBox item with Selenium.

 

Recently we received a few client requests about problems selecting RadComboBox item with WatiN – web application testing tool for .Net.

I researched the problem and here is sample code which selects the third item of RadComboBox:

public static void Main()  
 
    {  
        IE ie = new IE("http://localhost:1995/Default.aspx");   
          
        Image radComboBoxDropDownImage = ie.Image(Find.ById("idRadComboBox_Image"));  
 
        radComboBoxDropDownImage.Click();  
 
        Div divStudent3 = ie.Div(Find.ById("idRadComboBox_c2"));  
 
        divStudent3.FireEvent("onmouseover");  
 
        divStudent3.Click();  
 
    }  
 
 

The special feature here is that you have to mouse over the RadComboBox item before clicking on it. This peculiarity comes from RadComboBox source code and the events sequence which follows when clicking on RadComboBox item: MouseOver -> Click.

Hope it will help some people working with WatiN. 

 

 

4  comments

  • Daaron 29 May 2008
    I am one of the contributors to WatiN. I am concerned that idRadComboBox_c2 may not be the best way to identify the third item in the list. With Infragistics, I use their javascript objects to identify and fire the event on the appropriate item. Is there something similar with your controls? Alternatively, if the "_c2" ending denotes the third item in your controls, would you consider writing a very small facade class for WatiN?
  • Sendhil 30 May 2008
    Hi Elena, I use execScript & Rad's Client side object model to do this. Any drawbacks in using this approach? http://sendhil.spaces.live.com/blog/cns!30862CF919BD131A!1202.entry Thanks, Sendhil
  • Elena Tosheva 02 Jun 2008
    Hi Daaron, You can use the client-side api of RadComboBox instead. I just showed here one possible way how to select an item using DOM elements. Regards, Elena
  • Elena Tosheva 02 Jun 2008
    Hi Sendhil, No, there are no drawbacks using this approach. I have always preferred the use of client-side api in my tests. I didn’t know WatiN in details and that’s why I researched that particular problem of selecting an item using DOM elements as a client request. Thanks, Elena

Add comment

  1. Formatting options
       
      
     
     
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)