Methods & Tools Software Development Magazine

Software Development Magazine - Programming, Software Testing, Project Management, Jobs

Click here to view the complete list of tools reviews

This article was originally published in the Spring 2011 issue of Methods & Tools


Tellurium Automated Testing Framework

Vivek Mongolu, http://code.google.com/p/aost/

Tellurium Automated Testing Framework is an open source automated testing framework for testing web applications. Tellurium evolved from Selenium framework about 2 years ago with a different testing approach. Tellurium is built on UI module concept, which makes it possible to write reusable and easy to maintain tests against the dynamic RIA based web applications. UI module is collection of UI(DOM) elements grouped together. Current version is 0.8.0.

Web Site: http://code.google.com/p/aost/
Version Tested: Tellurium: 0.8.0, Trump plugin: 0.8.0-RC1, Tellurium IDE: 0.8.0-RC2
License & Pricing: Open Source
Support: User mailing list (tellurium-users@googlegroups.com)

Installation

The easiest way to create a Tellurium project is to use Tellurium Maven archetypes.

For a Tellurium JUnit project, use:

mvn archetype:create -DgroupId=your_group_id
   -DartifactId=your_artifact_id \
   -DarchetypeArtifactId=tellurium-junit-archetype \
   -DarchetypeGroupId=org.telluriumsource \
   -DarchetypeVersion=0.8.0 \
   -DarchetypeRepository=http://maven.kungfuters.org/content/repositories/releases

For a Tellurium TestNG project, use:

mvn archetype:create -DgroupId=your_group_id
   -DartifactId=your_artifact_id \
   -DarchetypeArtifactId=tellurium-testng-archetype \
   -DarchetypeGroupId=org.telluriumsource \
   -DarchetypeVersion=0.8.0 \
   -DarchetypeRepository=http://maven.kungfuters.org/content/repositories/releases

You can also use the reference project to create Tellurium project. Instructions can be found here http://code.google.com/p/aost/wiki/ReferenceProjectGuide

TrUMP plugin: Download the firefox plugin from: http://code.google.com/p/aost/downloads/detail?name=Trump-0.8.0-RC1.xpi&can=2&q

Tellurium-IDE plugin: Download the firefox plugin from: http://code.google.com/p/aost/downloads/detail?name=TelluriumIDE-0.8.0-RC2.xpi&can=2&q

Getting started with Tellurium

  1. Create the project structure using Tellurium Maven archetype.
  2. Create the User Interface(UI) module using TrUMP firefox plugin
  3. Create the reusable methods for different operations on the UI module.
  4. Create test cases in Java, Groovy or DSL. Tellurium supports JUnit/TestNG/easyb test cases.
  5. Run the Tests.

UI Module

Most existing web testing frameworks, like Selenium, primarily focus on individual UI elements such as links and buttons, Tellurium on the other hand, groups UI elements as UI objects into UI module.

For example to test the Google home page, first we create the Search UI in a Groovy class as follows:

ui.Container(uid: "GoogleSearchModule", clocator: [tag: "td"], group: "true"){
InputBox(uid: "Input", clocator: [title:"Google Search"])
SubmitButton(uid: "Search", clocator: [name:"btnG", value: "Google Search"])
SubmitButton(uid: "ImFeelingLucky", clocator:[value: "I'm Feeling Lucky"])
}

Here we are defining that the UI consists of one Input textbox element and two submit buttons.

Adoption of UI module makes Tellurium expressive and easy to understand in the context of tests. Tellurium sets the Object to Locator Mapping at runtime using the attributes from the composite locator(clocator). This makes Tellurium more robust and responsive to changes from internal UI elements.

In the test code locators are not used directly, instead UI elements are accessed by simply appending the uids along the path. To access Search button, use GoogleSearchModule.Search

Writing test code for the above UI can be done using Java or Groovy as follows:

@Test
public void searchTelluriumTest(){
   type "GoogleSearchModule.Input", "Tellurium test"
   click "GoogleSearchModule.Search"
   waitForPageToLoad 3000
   //Assertions here
}

Tellurium shines when dynamic web content is being tested. Complex dynamic web data can be easily defined using the Tellurium UI templates. For example, Issue Search page on the projects website can be represented as follows:

ui.Table(uid: "issueResult", clocator: [id: "resultstable", class: "results"], group: "true")
{
//Define the header elements
UrlLink(uid: "{header: any} as ID", clocator: [text: "*ID"])
UrlLink(uid: "{header: any} as Type", clocator: [text: "*Type"])
UrlLink(uid: "{header: any} as Status", clocator: [text: "*Status"])
UrlLink(uid: "{header: any} as Priority", clocator: [text: "*Priority"])
UrlLink(uid: "{header: any} as Milestone", clocator: [text: "*Milestone"])
UrlLink(uid: "{header: any} as Owner", clocator: [text: "*Owner"])
UrlLink(uid: "{header: any} as Summary", clocator: text: "*Summary + Labels"])
UrlLink(uid: "{header: any} as Extra", clocator: [text: "*..."])

//Define table body elements
//Column "Extra" for all Rows is TextBox
TextBox(uid: "{row: all, column -> Extra}", clocator: [:])
//For the rest, they are UrlLinks
UrlLink(uid: "{row: all, column: all}", clocator: [:])
}

Looking at the UI module we can infer that UI is an HMTL Table with the header row and the table body. Further, header columns can be differentiated by metadata in uid {header:any} and the content for header column is link. The whole body of the table is defined in last two lines as TextBox and UrlLink. Further we can infer that data for the column referenced by the Extra is cell with some text and every other cell is a link as defined in the uid {row:all, column: all}. To access the elements for testing in the above UI, use indexes

issueResult.header[1] returns the first column in the header row which is ID column.

issueResult[2][2] returns the cell for second row and second column.

Tellurium API provides with various methods to access and manipulate the web data. Tellurium enforces clear separation between the UI and the test code. In an agile world where UI changes rapidly, having this clear separation makes it easier to modify UI with minimal changes to the test code.

Tellurium Sub-projects

  • Tellurium started as small core project but quickly expanded into multiple sub-projects.
  • Tellurium Core: UI module, APIs, DSL, Object to Runtime Locator mapping, test support.
  • Tellurium Engine: Based on Selenium core with UI module, CSS selector support, macro command and exception hierarchy support.
  • Tellurium UI Module Plugin(Trump): Firefox plugin that automatically generates the UI module after user selects the UI elements on the web page being tested. Trump validates the UI module by evaluating each UI elements attributes, then generates the runtime locator and verifies the locators are valid.
  • Tellurium-IDE: Firefox plugin that QA group and non programmers can use to record user actions on the web page and replay them. Plugin automatically generates Tellurium commands and UI modules in DSL script format. The DSL script can be exported as Groovy script. Replaying the script is done by the built in test runner.
  • TelluriumWorks: Java Swing application to edit and run Tellurium-IDE generated test scripts.

Testing Approach

Tellurium works in two modes. First mode works as a wrapper to the Selenium framework. Tellurium core generates the runtime locator based on the attributes defined in clocator of the UI module. The generated locator is then passed in Selenium calls to the Selenium core with Tellurium extensions.

The following diagram illustrates this flow.

Second mode uses Tellurium Engine. Tellurium Core will convert the UI module into JSON notation and passes it to the Tellurium Engine when the UI module is used first time. Engine uses the Santa algorithm to locate the whole UI module and caches it. For subsequent calls, the cached UI module will be used instead of locating again, thereby improving the test execution speed.

The following diagram illustrates this flow.

Other features

  • Uses abstract UI objects to encapsulate web UI elements such as InputButton, Selector, UrlLink, List, Table, Frame.
  • UI templates and UID Description Language(UDL) are used to represent UI elements like HTML Tables or List where the content changes dynamically.
  • Internationalization(i18n) support for Strings and exception messages.
  • Supports widgets for re-usability.
  • Supports Data-driven test support.
  • CSS selectors are supported to improve test speed in IE.
  • Locator caching and command bundling further improve the test speed.

Documentation

The general documentation is available from the project home page. The user guide can be found at http://code.google.com/p/aost/wiki/UserGuide070Introduction?tm=6

PDF version of the user guide is also available at http://code.google.com/p/aost/downloads/detail?name=tellurium-reference-0.7.0.pdf&can=2&q

Related Tools

Selenium

JUnit

TestNG

easyb


More Software Testing Content


Click here to view the complete list of tools reviews