AgileJedi.com WatiN Evaluation

June 28, 2008

AgileJedi.com 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 InCisif.net.

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

public const string STR_InCisifNetSupportEMail  = "support@incisif.net";
public const string STR_MyGMailUserName         = "MY-USERNAME";
public const string STR_MyGMailPassWord         = "MY-PASSWORD";

public void LogInToGmail(){

    Page.URL = "www.gmail.com";
    Page.WaitForPage("/ServiceLogin");

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

    Page.Control("signIn").Click();
    Page.WaitForPage("http://mail.google.com/mail/?ui", true, 13); // Wait for 13 urls to be downloaded containing the text
}

public void LogOffGMail(){

    Page.ControlOfType("Sign out","htmlanchorelementclass","v1").Click();
    Page.WaitForPage(@"/ServiceLogin");
}

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

    using ( InCisif.net.Library.Test t = new InCisif.net.Library.Test(Language.CSharp, this) ) {

        LogInToGmail();

        // 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
        // InCisif.net.Library.HTMLControl composeMailButtonSPANWithId = Page.Control("comp","v1&quot;
        // InCisif.net.Library.HTMLControl composeMailButtonDIVtag     = Page.ControlOfType("Compose Mail","htmldivelementclass","v1&quot;

        Page.WaitForControl("comp","v1").Click(MouseClickType.Left); // Use Page.WaitForControl Ajax Application
        Page.WaitForPage(@"/mail");
        
        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.Control("snd","v2").Click();
        Page.WaitForPage("http://mail.google.com/mail", true, 2); // Wait for 2 urls to be downloaded containing the text

        LogOffGMail();

        t.Passed = true;

    }
}