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

May 2, 2009

Getting Started With WatiN

Filed under: watin — haditeo @ 6:15 pm
Tags: ,

Today i went to library and searched for books on TDD. Came across this particular book Pragmatic Unit Testing in C# with NUnit

Actually i need to find a good way to automate my UI testing since my current tasks now mostly deal with Javascript, Telerik 3rd ASP.NET Ajax and finally Dynamics CRM SDK

For the starter, i have googled across this
Getting started with WatiN and remember to create an app.config file and configure the STA Thread

Currently i am learning in applying TDD. For the UI test now, i am using NUnit to automate the testing.

I have setup the ie object by using this code snippet :

IE ie = new IE("http://localhost/webform1.aspx");

It was quite easy to use WatiN.
1) To configure a textbox field, i am using this code snippet :

ie.TextField(Find.ByName("YourTextBoxName")).TypeText("AnyTextThatYouWouldLikeToEnter");

2) I am using an image button to open the RadWindow. This is the code snippet :

ie.Image(Find.ById("TheButtonId")).Click();

3) How to get hold of the Modal Dialog that has been opened by RadWindow ? I used IE Developer Tool and find out that an IFrame is invoked. This is the code snippet :

Frame radWindowFrame = ie.Frame(Find.ByName("RadWindowObject"));

4) Currently i have encountered an issue. I have performed an Ajax request by clicking a client side button to retrieve tabular data and populate back to the client using grid. WatiN executes my line of code synchronously so i need to check at the client side whether asynchronous postback has been successfully performed so that i can proceed with my WatiN code.

Create a free website or blog at WordPress.com.