Testing: Selenium: ZimbraSelenium SampleTestCase
General Information
Below is a sample test case with descriptions.
Harness Overview
Sample Test Case
Objective
The sample test case has the objective: "Send a mail using text editor"
Code
package com.zimbra.qa.selenium.projects.ajax.tests.mail.compose; import java.util.HashMap; import org.testng.annotations.Test; import com.zimbra.qa.selenium.framework.items.*; import com.zimbra.qa.selenium.framework.ui.*; import com.zimbra.qa.selenium.framework.util.*; import com.zimbra.qa.selenium.projects.ajax.core.AjaxCommonTest; import com.zimbra.qa.selenium.projects.ajax.ui.mail.FormMailNew; public class CreateMailText extends AjaxCommonTest { @SuppressWarnings("serial") public CreateMailText() { logger.info("New "+ CreateMailText.class.getCanonicalName()); // All tests start at the login page super.startingPage = app.zPageMail; super.startingAccountPreferences = new HashMap<String , String>() Template:Put("zimbraPrefComposeFormat", "text");; } @Test( description = "Send a mail using Text editor", groups = { "sanity" }) public void CreateMailText_01() throws HarnessException { // Create the message data to be sent MailItem mail = new MailItem(); mail.dToRecipients.add(new RecipientItem(ZimbraAccount.AccountA())); mail.dSubject = "subject" + ZimbraSeleniumProperties.getUniqueString(); mail.dBodyText = "body" + ZimbraSeleniumProperties.getUniqueString(); // Open the new mail form FormMailNew mailform = (FormMailNew) app.zPageMail.zToolbarPressButton(Button.B_NEW); ZAssert.assertNotNull(mailform, "Verify the new form opened"); // Fill out the form with the data mailform.zFill(mail); // Send the message mailform.zSubmit(); MailItem received = MailItem.importFromSOAP(ZimbraAccount.AccountA(), "subject:("+ mail.dSubject +")"); // TODO: add checks for TO, Subject, Body ZAssert.assertEquals(received.dFromRecipient.dEmailAddress, app.zGetActiveAccount().EmailAddress, "Verify the from field is correct"); ZAssert.assertEquals(received.dToRecipients.get(0).dEmailAddress, ZimbraAccount.AccountA().EmailAddress, "Verify the to field is correct"); ZAssert.assertEquals(received.dSubject, mail.dSubject, "Verify the subject field is correct"); ZAssert.assertStringContains(received.dBodyText, mail.dBodyText, "Verify the body field is correct"); } }
Walk Through