Testing: Selenium: ZimbraSelenium SampleTestCase

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

General Information

Below is a sample test case with descriptions.

Harness Overview

See Zimbra Selenium Overview

Sample Test Case

Objective

The sample test case has the objective: "Send a mail using text editor"

Walk Through

See the code below with comments that walk through the test steps.


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;
import com.zimbra.qa.selenium.projects.ajax.ui.mail.FormMailNew.Field;


// Test case classes extend from a basic AjaxCommonTest class, which
// includes functionality that is common to all test cases
//
public class CreateMailText extends AjaxCommonTest {

	public CreateMailText() {
		
		// The AjaxCommonTest class defines a log4j Logger object
		// named "logger".  This "logger" can be used to output 
		// INFO level logging to the test results output folder
		//
		logger.info("New "+ CreateMailText.class.getCanonicalName());
		
		// Define a starting page, which will be active before
		// each test method.  For example, calendar test cases
		// will start in the calendar app automatically
		//
		super.startingPage = app.zPageMail;
		
		// The harness authenticates to the app automatically, using
		// the account defined by ZimbraAccount.AccountZWC (for ajax),
		// ZimbraAccount.AccountZMC (for mobile), ZimbraAccount.AccountZHC
		// (for HTML-lite), etc.
		//
		// Define any user preferences required for the test methods in
		// this class.  The test account will have these preferences
		// set automatically.
		//
		//
		Map<String, String> prefs = new HashMap<String, String>();
		prefs.put("zimbraPrefComposeFormat", "text");
		super.startingAccountPreferences = prefs;
		
	}
	
	// TestNG methods must be decorated with the @Test attribute to be
	// included in test execution
	@Test(	
			
			// Use the description to specify the test case objective
			description = "Send a mail using Text editor",
			
			// Zimbra uses sanity, smoke, functional groups.  See
			// the wiki for more information, definitions
			groups = { "sanity" }
		)
	public void CreateMailText_01() throws HarnessException {
		
		
		// Create a unique string to be used for the subject,
		// which minimizes the search results later in the test
		//
		String subject = "subject" + ZimbraSeleniumProperties.getUniqueString();
		String body = "text" + ZimbraSeleniumProperties.getUniqueString();
		
		
		// Use the ajax "app" object, which is defined in the base AjaxCommonTest object
		//
		// The "app" object contains a "zPageMail" object, which interfaces with
		// the "mail" tab.
		//
		// The zPageMail object has methods that can be used to click on the "NEW" button
		//
		// Certain button actions return other objects.  In this case, a 'new mail compose'
		// screen opens, which is a "FormMailNew" object in the harness.
		//
		FormMailNew mailform = (FormMailNew) app.zPageMail.zToolbarPressButton(Button.B_NEW);
		
		// The ZAssert class extends the base java Assert class.  Basically,
		// the ZAssert class has additional custom logging and result counters.
		//
		ZAssert.assertNotNull(mailform, "Verify the new form opened");
		
		// Use the FormMailNew object to fill out the fields
		//
		// For convenience, the ZimbraAccount class has two static accounts, AccountA
		// and AccountB, that can be used for sender or recipients of sample emails 
		// from the test account.
		//
		mailform.zFillField(Field.To, ZimbraAccount.AccountA().EmailAddress);
		mailform.zFillField(Field.Subject, subject);
		mailform.zFillField(Field.Body, body);
		
		// Send the message
		mailform.zSubmit();
				
		
		// The framework.items.* classes have helper methods to import data
		// using SOAP into plain old java objects.  For instance, the
		// MailItem.importFromSOAP() will use Zimbra's SOAP API requests SearchRequest
		// followed by GetMsgRequest to import the message into the "received" object
		//
		MailItem received = MailItem.importFromSOAP(ZimbraAccount.AccountA(), "subject:("+ subject +")");
		
		
		// Verify the receipient message contains the correct data
		//
		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, subject, "Verify the subject field is correct");
		ZAssert.assertStringContains(received.dBodyText, body, "Verify the body field is correct");
		
	}

}




Verified Against: unknown Date Created: 11/7/2007
Article ID: https://wiki.zimbra.com/index.php?title=Testing:_Selenium:_ZimbraSelenium_SampleTestCase Date Modified: 2015-03-24



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search