Random Musings

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.

Advertisements

Leave a Comment »

No comments yet.

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

Create a free website or blog at WordPress.com.

%d bloggers like this: