Using WatiN to test browse Yahoo mail.


The objective of this exercise is to compare testing of a web site (Yahoo Mail) with WatiN to the test previously done with AutoIt:

Automating Internet Explorer with Auto It. (Windows Tasks Automation software)

The first major advantage is the availability of the Test Recorder. This Test Recorder is able to get the names or id’s (and other properties) of the IExplorer. The Test Recorder is available from: A big plus is that it can generate source code in VB.NET. (The beta 2 version is not generating C# code at the moment)


Note: the note in red in the above capture: “Scripting to VB.Net and copying to clipboard.”

I modified the example shown in: in order to have the code in C# to access, login, and click on Mail.

I have a video that shows the recording process and the code generated using the Test Recorder:

Notice that the example is done with Visual Studio 2003. Since I used Visual Studio Express 2005 there is a minor difference: when adding the Reference to the Project, I needed to click on the Browse tab.

During this exercise I came across the need to address the log-in button in Yahoo but it was not obvious how to invoke it. Then I ran the recorder, compiled the script to VB.Net Console and then copied the results to the console. The button I needed was: Button btn_save = window.Button(Find.ByName(“save”));

Since I am using the C# version I coded the call to the button as:



1. A useful tool to find out the names, id’s, etc of IExplorer fields is the ie developer toolbar.

2. Here is the C# code:

//**WatiN example**
// Adapted by Omar Flores
using System;
using WatiN.Core;
using System.Threading;

namespace WatiNGettingStarted
class WatiNConsoleExample
static void Main(string[] args)
// Open a new Internet Explorer window and
// goto the google website.
IE ie = new IE(“”); //(“http://localhost/”);

// Find the search text field and type Watin in it.

// Find the search text field and type Watin in it.

// Click the Google search button.

// Click the Google search button.

// Uncomment the following line if you want to close
// Internet Explorer and the console window immediately.


One Response to “Using WatiN to test browse Yahoo mail.”

  1. Vladimir Says:

    The automated test area looks interesting, Would be nice to implement your own UI, and integrate some different test core dlls (different free providers) , that could be interesting. I looked something like that with other commercial programs. Example 1. There are some comercial ZIP programs that get advantage of alredy done free libs.

    Example 2. There are some ISO image commercial programs that calls underneath ISO free libs like the nero ones.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: