WatiN Evaluation

June 28, 2008 WatiN Evaluation

2/26/2008 4:59:00 AM

AgileJedi wrote a nice evaluation of WatiN automating GMail at Webtest Tool Round-up (Round 1:WatiN).

GMail is not the most easy web application to automate, so I finally tried with

From AgileJedi you can download the C# code using WatiN and here is the C# code using

public const string STR_InCisifNetSupportEMail  = "";
public const string STR_MyGMailUserName         = "MY-USERNAME";
public const string STR_MyGMailPassWord         = "MY-PASSWORD";

public void LogInToGmail(){

    Page.URL = "";

    Page.WaitForControl("Email").Text   =   STR_MyGMailUserName;
    Page.Control("Passwd").Text         =   STR_MyGMailPassWord;

    Page.WaitForPage("", true, 13); // Wait for 13 urls to be downloaded containing the text

public void LogOffGMail(){

    Page.ControlOfType("Sign out","htmlanchorelementclass","v1").Click();

["Test's Comment",1,TestPriority.High)]  
public void GMail_ComposeAndCheckEmail(){

    using ( t = new, this) ) {


        // To get the "Compose Mail" control we can use : <SPAN id="comp">, or the <DIV>
        // The first one is better because we use the id, rather than the text
        // composeMailButtonSPANWithId = Page.Control("comp","v1&quot;
        // composeMailButtonDIVtag     = Page.ControlOfType("Compose Mail","htmldivelementclass","v1&quot;

        Page.WaitForControl("comp","v1").Click(MouseClickType.Left); // Use Page.WaitForControl Ajax Application
        Page.WaitForControl("to","v2").Text         =   STR_InCisifNetSupportEMail;
        Page.Control("subject","v2").Text           =   "GMAIL TEST";
        Page.Control("hc_compose","v2").InnerText   =   "Hello!"; // This control is a <DIV> and that is the way you define the text of the email

        Page.WaitForPage("", true, 2); // Wait for 2 urls to be downloaded containing the text


        t.Passed = true;