All posts

How to select RadComboBox item with WatiN

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. 

 

 

Facebook DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Furl it!

Comments  4

  • 29 May, 11:57 AM

    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?

    Daaron

  • 30 May, 03:58 AM

    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

    Sendhil

  • 2 Jun, 02:36 AM

    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

  • 2 Jun, 02:41 AM

    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

    Elena Tosheva

Post a comment!
  1. Formatting options
       
     
     
     
     
       
  2. Security image