SlideShare uma empresa Scribd logo
1 de 9
Baixar para ler offline
Build Manageable & Robust Automated UI Tests with Tellurium

            Jian Fang, Vivek Mongolu, Matt Senter, and Haroon Rasheed

Why Tellurium?

The Tellurium Automated Testing Framework (Tellurium) is a UI module-based open source
automated testing framework for web applications. Tellurium is built on top of Selenium and
is targeted to address the following challenges in web testing:

     • Robust/Responsive to Changes: A good automated web testing tool should be
       able to address the changes in the web context to some degree so that users do not
       need to keep updating the test code frequently.
     • Ajax for Dynamic Web Content: Web applications have many benefits over
       desktop applications; For example, they have no installation and the application
       updates are instantaneous and easier to support. Ajax is a convenient way to
       update a part of the web page without refreshing the whole page. AJAX makes web
       applications richer and more user-friendly. The web context for an Ajax application
       is usually dynamic. For example, in a data grid, the data and number of rows keep
       changing at runtime.
     • JavaScript Events: JavaScript is everywhere on the web today. Many web
       applications are JavaScript heavy. To test JavaScript, the automated testing
       framework should be able to trigger JavaScript events in a very convenient way.
     • Re-usability: Many web applications use the same UI module for different parts of
       the application. The adoption of JavaScript frameworks such as Dojo and ExtJS
       increases the chance of using the same UI module for different web applications. A
       good testing framework should also be able to provide the re-usability of test
       modules.
     • Expressiveness: The testing framework should be able to provide users without
       much coding experience the ability to easily write test code or scripts in a familiar
       way, like by using a domain specific language (DSL).
     • Easy to Maintain: In an agile world, software development is based on iterations,
       and new features are added on in each sprint. The functional tests or user
       acceptance tests must be refactored and updated for the new features. The testing
       framework should provide the flexibility for users to maintain the test code very
       easily.

The Selenium web testing framework is one of the most popular open source automated
web testing frameworks. It's a ground-breaking framework that offers many unique features
and advantages such as browser based testing, Selenium Grid, and "record and replay" of
user interactions with the Selenium IDE. However, it has the drawback of being difficult to
refactor and maintain. Take the following Selenium test code as an example:

   setUp("http://www.google.com/", "*chrome");
   selenium.open("/");
   selenium.type("q", "Selenium test");
   selenium.click("//input[@value='Google Search' and @type='button']");

Do you know what UI looks like that the above code is testing assume you are not familiar
with Google web site? What does the locator q mean here? What if the XPath
//input[@value='Google Search' and @type='button'] becomes invalid due to changes on
the web? Most likely, you have to go through the test code to locate the lines you need to
update. What if you have tens or hundreds of locators in your test code? Creating the test
code using Selenium IDE is easy, but it is difficult to generalize and refactor. Refactoring is
a much more tedious and painful procedure than regenerating new test code from scratch
because of the use of hard-coded locators and the coupling of locators with test code.
Maintaining the code is a hassle because the test code is not structured.

The majority of existing web testing tools/frameworks focus on individual UI elements such
as links and buttons. Tellurium takes a new approach for automated web testing using the
concept of the UI module. The UI module is a collection of UI elements grouped together.
Usually, the UI module represents a composite UI object in the format of nested basic UI
elements. For example, the Google search UI module can be expressed 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"])
}

First of all, Tellurium does not use "record and replay." Instead, it uses the Tellurium Firefox
plug-in (Trump) to generate the UI module (not test code) for you. Then you need to create
your test code based on the UI module. In this way, the UI and the test code are decoupled.
The structured test code in Tellurium makes it much easier to refactor and maintain the
code. The composite locator uses UI element attributes to define the UI, and the actual
locator (e.g. xpath or jQuery selector) will be generated at runtime. Any updates to the
composite locator will lead to different runtime locators, and the changes inside the UI
module are localized. The Group locating is used to remove the dependency of the UI
objects from external UI elements (i.e. external UI changes will not affect the current UI
module for most cases) so that your test code is robust and responsive to changes up to a
certain level.




Tellurium Overview

Tellurium defines a set of Java UI objects, such as InputButton, Selector, List, Table, and
Frame, which users can use directly. The basic UI Object works as the base class for all UI
objects and it includes the following attributes:

    1.   uid: UI object's identifier
    2.   namespace: used for XHTML
    3.   locator: the locator of the UI object, could be a base locator or a composite locator
    4.   respond: the JavaScript events the UI object can respond to. The value is a list.

All UI Objects inherit the above attributes and methods and many UI objects have their
extra attributes and methods. For example, the List object has one special attribute
"separator", which is used to indicate the tag used to separate different List child UI
elements. Tellurium supports two types of locators: base locator and composite locator. The
base locator is a relative XPath. The composite locator, denoted by "clocator", specifies a set
of attributes for the UI object and the actual locator will be derived automatically by
Tellurium at runtime.
The Composite Locator is defined as follows:

class CompositeLocator {
    String header
    String tag
    String text
    String trailer
    def position
    boolean direct
    Map<String, String> attributes = [:]
}

To use the composite locator, you need to use "clocator" with a map as its value. For
example:

clocator: [key1: value1, key2: value2, ...]

The default attributes include "header", "tag", "text", "trailer", "position", and "direct". They
are all optional. The "direct" attribute specifies whether this UI object is a direct child of its
parent UI, and the default value is "false".

If you have additional attributes, you can define them in the same way as the default
attributes, for example:

clocator: [tag: "div", value: "Tellurium home"]

In the above Tellurium UI module, the "GoogleSearchModule" Container includes a "group"
attribute. The group attribute is a flag for the Group Locating Concept. Usually, the XPath
generated by Selenium IDE, XPather, or other tools is a single path to the target node such
as:

//div/table[@id='something']/div[2]/div[3]/div[1]/div[6]

No sibling node's information is used here. What is wrong with this? The XPath depends too
much on information from nodes far away from the target node. In Tellurium, we try to
localize the information and reduce this dependency by using sibling information or local
information. For example, in the above google UI module, the group locating concept will try
to find the "td" tag with its children as "Input", "Search" button, and "ImFeelingLucky"
button. In this way, we can reduce the dependencies of the UI elements inside a UI module
on external UI elements to make the UI definition more robust.

The Tellurium framework architecture is shown as in Figure 1.
Figure 1. Tellurium Architecture.

The DSL object parser will parse the DSL object definition recursively and use object
builders to build the objects on the fly. The Object Locator Mapping (OLM) is the core of the
Tellurium framework and it includes UI ID mapping, XPath builder, jQuery selector builder,
and Group Locating.

The UI ID supports nested objects. For example, "GoogleSearchModule.Search" stands for a
button "Search" inside a container called "GoogleSearchModule". The UI ID also supports
one-dimensional and two-dimensional indices for table and list. For example,
"main.table[2][3]" stands for the UI object of the 2nd row and the 3rd column of a table
inside the container "main".
XPath builder can build the XPath from the composite locator, i.e., a set of attributes.
Starting with version 0.6.0, Tellurium supports jQuery selectors to address the problem of
poor performance of XPath in Internet Explorer. jQuery selector builders are used to
automatically generate jQuery selectors instead of XPath with the following advantages:

     • Faster performance in IE.
     • Leverage the power of jQuery to retrieve bulk data from the web by testing with one
       method call.
     • New features provided by jQuery attribute selectors.

The Group Locating Concept (GLC) exploits the group information inside a collection of UI
objects to help us find the locator of the collection of UI objects.

The Eventhandler will handle all events like "click", "type", "select", and so on. The Data
Accessor is used to fetch data or UI status from the DOM. The dispatcher will delegate all
calls it receives from the Eventhandler and the data accessor to the connector, which
connects to the Tellurium engine. The dispatcher is designed to decouple the rest of the
Tellurium framework from the base test driving engine so that we can switch to a different
test driving engine by simply changing the dispatcher logic. The Engine is a customized
Selenium server with jQuery selector support and a lot of other enhancements to Selenium
Core.

Tellurium evolved out of Selenium, but the UI testing approach is completely different.
Tellurium enforces the separation of UI modules from test code, making refactoring easy.
For example, once you defined the Google Search UI module shown above, you can write
your test code as follows:

type "GoogleSearchModule.Input", "Tellurium test"
click "GoogleSearchModule.Search"

Getting Started

Tellurium Core framework is implemented in Groovy and tests can be written in Groovy,
JUnit, TestNG, or pure dsl scripts. Tellurium supports both Ant and Maven. The easiest way
to create a new Tellurium test project is to use Tellurium Maven Archetypes. For example,
you can use the following Maven command to a Tellurium project based on Tellurium 0.7.0
SNAPSHOT with JUnit 4 support.

mvn archetype:create -DgroupId=org.telluriumsource -DartifactId=demo
-DarchetypeArtifactId=tellurium-junit-archetype -DarchetypeGroupId=tellurium
-DarchetypeVersion=0.7.0-SNAPSHOT
-DarchetypeRepository=http://kungfuters.org/nexus/content/repositories/
snapshots

After the project is created, you will find the following files

pom.xml
src
src/main
src/main/groovy
src/main/resources
src/test
src/test/groovy
src/test/groovy/module
src/test/groovy/module/GoogleSearchModule.groovy
src/test/groovy/test
src/test/groovy/test/GoogleSearchTestCase.java
src/test/resources
TelluriumConfig.groovy

The GoogleSearchModule UI module is created using the Trump plugin and the
GoogleSearchTestCase is an example Tellurium JUnit Test case. the TelluriumConfig.groovy
includes Tellurium project settings and you can customize them to you need.

If you want to run the tests in command line, you can use the following Maven command:

mvn test

Let us look closer at the UI module GoogleSearchModule.

public class GoogleSearchModule extends DslContext {

  public void defineUi() {
    ui.Container(uid: "Google", clocator: [tag: "table"]) {
      InputBox(uid: "Input", clocator: [tag: "input", title: "Google Search", name: "q"])
      SubmitButton(uid: "Search", clocator: [tag: "input", type: "submit", value: "Google
Search", name: "btnG"])
      SubmitButton(uid: "ImFeelingLucky", clocator: [tag: "input", type: "submit", value:
"I'm Feeling Lucky", name: "btnI"])
    }
  }

    public void doGoogleSearch(String input) {
      type "Google.Input", input
      pause 500
      click "Google.Search"
      waitForPageToLoad 30000
    }

    public void doImFeelingLucky(String input) {
      keyType "Google.Input", input
      pause 500
      click "Google.ImFeelingLucky"
      waitForPageToLoad 30000
    }
}

The UI module is a Groovy class, which extends Tellurium DslContext class. The defineUi()
method defined a UI module "Google" for the Google search UI with one input box and two
search buttons. Two methods are defined for this UI module, i.e., doGoogleSearch for
search by clicking the "Google Search" button and doImFeelingLucky for the "I'm Feeling
Lucky" button.

The actual test class just like regular JUnit 4 class by extending TelluriumJavaTestCase.
public class GoogleSearchTestCase extends TelluriumJavaTestCase {
  private static GoogleSearchModule gsm;

  @BeforeClass
  public static void initUi() {
    gsm = new GoogleSearchModule();
    gsm.defineUi();
    connectSeleniumServer();
  }

  @Before
  public void connectToGoogle() {
    connectUrl("http://www.google.com");
  }

  @Test
  public void testGoogleSearchWithXPath() {
    //turn off jQuery Selector
    gsm.disableJQuerySelector();
    gsm.doGoogleSearch("tellurium Groovy Test");
  }

  @Test
  public void testGoogleSearchFeelingLuckyWithXPath() {
    //turn off jQuery Selector
    gsm.disableJQuerySelector();
    gsm.doImFeelingLucky("tellurium automated Testing");
  }

  @Test
  public void testGoogleSearchWithSelector() {
    //turn on jQuery Selector
    gsm.useJQuerySelector();
    gsm.disableSelectorCache();
    gsm.doGoogleSearch("tellurium Groovy Test");
  }

  @Test
  public void testGoogleSearchFeelingLuckyWithSelector() {
    //turn on jQuery Selector
    gsm.useJQuerySelector();
    gsm.disableSelectorCache();
    gsm.doImFeelingLucky("tellurium automated Testing");
  }

  @Test
  public void testGoogleSearchWithSelectorCached() {
    //turn on jQuery Selector
    gsm.useJQuerySelector();
    gsm.enableSelectorCache();
    gsm.setCacheMaxSize(10);
    gsm.doGoogleSearch("tellurium Groovy Test");
  }
@Test
    public void testGoogleSearchFeelingLuckyWithSelectorCached() {
      //turn on jQuery Selector
      gsm.useJQuerySelector();
      gsm.enableSelectorCache();
      gsm.setCacheMaxSize(10);
      gsm.doImFeelingLucky("tellurium automated Testing");
    }

    @Test
    public void testDump(){
      gsm.dump("Google");
    }
}

The initUi() method instantiate the UI module and it provides different test cases for testing
"Google Search" and "I'm Feeling Lucky" buttons. As you may notice, Tellurium UI module is
agnostic to the locator. XPath is the default locator. If you want to use jQuery selector, you
can simply call useJQuerySelector(). The enableSelectorCache() method can be used
together with useJQuerySelector() to turn on jQuery selector caching in the Selenium core
to improve the test speed further. Apart from that, Tellurium provides a handy method
dump() to print out the runtime locator the Tellurium core generates for your UI module in
offline mode.

Furthermore, you can create a Tellurium TestNG project by using
tellurium-testng-archetype. Tellurium UI Model Plugin (Trump) is a Firefox plugin to
automatically create UI modules for you.



Summary

Tellurium introduces a new approach to test web applications based on UI modules. The UI
module makes it possible to build locators for UI elements at runtime. First, this makes
Tellurium robust and responsive to changes from internal UI elements. Second, the UI
module makes Tellurium expressive. A UI element can be referred to simply by appending
the names (uid) along the path to the specific element. This also enables Tellurium's Group
Locating feature, making composite objects reusable, and addressing dynamic web pages.
Tellurium does Object to Locator Mapping (OLM) automatically at run time so that UI
objects can be defined simply by their attributes using Composite Locators. Tellurium uses
the Group Locating Concept (GLC) to exploit information inside a collection of UI
components so that locators can find their elements. It also defines a set of DSLs for web
testing. Furthermore, Tellurium uses UI templates to define sets of dynamic UI elements at
runtime. As a result, Tellurium is robust, expressive, flexible, reusable, and easy to
maintain.

Resources

     1. Tellurium Project website, http://code.google.com/p/aost
     2. Tellurium User Group, http://groups.google.com/group/tellurium-users
     3. Tellurium 0.6.0 User Guide, http://aost.googlecode.com/files/
        TelluriumUserGuide.0.6.0.pdf
Manageable Robust Automated Ui Test

Mais conteúdo relacionado

Mais procurados

Automated Xcode 7 UI Testing
Automated Xcode 7 UI TestingAutomated Xcode 7 UI Testing
Automated Xcode 7 UI TestingJouni Miettunen
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQueryBhushan Mulmule
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptRohan Chandane
 
Built to last javascript for enterprise
Built to last   javascript for enterpriseBuilt to last   javascript for enterprise
Built to last javascript for enterpriseMarjan Nikolovski
 
Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Nicholas Zakas
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법Jeado Ko
 
Integrating into Visual Studio settings
Integrating into Visual Studio settingsIntegrating into Visual Studio settings
Integrating into Visual Studio settingsPVS-Studio
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Jeado Ko
 
"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2Tadas Jurelevičius
 
Secret unit testing tools
Secret unit testing toolsSecret unit testing tools
Secret unit testing toolsDror Helper
 
Java Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialJava Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialSagun Dhakhwa
 
Learning MVC Part 3 Creating MVC Application with EntityFramework
Learning MVC Part 3 Creating MVC Application with EntityFrameworkLearning MVC Part 3 Creating MVC Application with EntityFramework
Learning MVC Part 3 Creating MVC Application with EntityFrameworkAkhil Mittal
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOSjimmyatmedium
 
iOS UI Testing in Xcode
iOS UI Testing in XcodeiOS UI Testing in Xcode
iOS UI Testing in XcodeJz Chang
 

Mais procurados (20)

Automated Xcode 7 UI Testing
Automated Xcode 7 UI TestingAutomated Xcode 7 UI Testing
Automated Xcode 7 UI Testing
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScript
 
Built to last javascript for enterprise
Built to last   javascript for enterpriseBuilt to last   javascript for enterprise
Built to last javascript for enterprise
 
Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
Integrating into Visual Studio settings
Integrating into Visual Studio settingsIntegrating into Visual Studio settings
Integrating into Visual Studio settings
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
 
"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2
 
Secret unit testing tools
Secret unit testing toolsSecret unit testing tools
Secret unit testing tools
 
Java Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialJava Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component Tutorial
 
Learning MVC Part 3 Creating MVC Application with EntityFramework
Learning MVC Part 3 Creating MVC Application with EntityFrameworkLearning MVC Part 3 Creating MVC Application with EntityFramework
Learning MVC Part 3 Creating MVC Application with EntityFramework
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
 
JSP Technology II
JSP Technology IIJSP Technology II
JSP Technology II
 
java swing
java swingjava swing
java swing
 
iOS UI Testing in Xcode
iOS UI Testing in XcodeiOS UI Testing in Xcode
iOS UI Testing in Xcode
 
Overview of JEE Technology
Overview of JEE TechnologyOverview of JEE Technology
Overview of JEE Technology
 
Android layouts
Android layoutsAndroid layouts
Android layouts
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 

Destaque

Tellurium 0.6.0 User Guide
Tellurium 0.6.0 User GuideTellurium 0.6.0 User Guide
Tellurium 0.6.0 User GuideJohn.Jian.Fang
 
Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5John.Jian.Fang
 
Ten Minutes To Tellurium
Ten Minutes To TelluriumTen Minutes To Tellurium
Ten Minutes To TelluriumJohn.Jian.Fang
 
Tellurium 0.7.0 presentation
Tellurium 0.7.0 presentationTellurium 0.7.0 presentation
Tellurium 0.7.0 presentationJohn.Jian.Fang
 
Tellurium reference Document 0.7.0
Tellurium reference Document 0.7.0Tellurium reference Document 0.7.0
Tellurium reference Document 0.7.0John.Jian.Fang
 

Destaque (6)

Tellurium 0.6.0 User Guide
Tellurium 0.6.0 User GuideTellurium 0.6.0 User Guide
Tellurium 0.6.0 User Guide
 
Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5
 
Ten Minutes To Tellurium
Ten Minutes To TelluriumTen Minutes To Tellurium
Ten Minutes To Tellurium
 
Tellurium 0.7.0 presentation
Tellurium 0.7.0 presentationTellurium 0.7.0 presentation
Tellurium 0.7.0 presentation
 
Atomic Structure
Atomic StructureAtomic Structure
Atomic Structure
 
Tellurium reference Document 0.7.0
Tellurium reference Document 0.7.0Tellurium reference Document 0.7.0
Tellurium reference Document 0.7.0
 

Semelhante a Manageable Robust Automated Ui Test

Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009John.Jian.Fang
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
DSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsDSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsMikalai Alimenkou
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaAgile Testing Alliance
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxMikalai Alimenkou
 
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамDSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамSQALab
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010vchircu
 
Selenium Testing Training in Bangalore
Selenium Testing Training in BangaloreSelenium Testing Training in Bangalore
Selenium Testing Training in Bangalorerajkamal560066
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Lars Vogel
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksŁukasz Morawski
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshersNaga Mani
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 

Semelhante a Manageable Robust Automated Ui Test (20)

Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
DSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsDSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional tests
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
 
Mini-Training: Javascript Patterns
Mini-Training: Javascript PatternsMini-Training: Javascript Patterns
Mini-Training: Javascript Patterns
 
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамDSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
 
Selenium Testing Training in Bangalore
Selenium Testing Training in BangaloreSelenium Testing Training in Bangalore
Selenium Testing Training in Bangalore
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation Frameworks
 
Spring boot
Spring bootSpring boot
Spring boot
 
ASP.NET MVC3 RAD
ASP.NET MVC3 RADASP.NET MVC3 RAD
ASP.NET MVC3 RAD
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
Stmik bandung
Stmik bandungStmik bandung
Stmik bandung
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 

Último

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Manageable Robust Automated Ui Test

  • 1. Build Manageable & Robust Automated UI Tests with Tellurium Jian Fang, Vivek Mongolu, Matt Senter, and Haroon Rasheed Why Tellurium? The Tellurium Automated Testing Framework (Tellurium) is a UI module-based open source automated testing framework for web applications. Tellurium is built on top of Selenium and is targeted to address the following challenges in web testing: • Robust/Responsive to Changes: A good automated web testing tool should be able to address the changes in the web context to some degree so that users do not need to keep updating the test code frequently. • Ajax for Dynamic Web Content: Web applications have many benefits over desktop applications; For example, they have no installation and the application updates are instantaneous and easier to support. Ajax is a convenient way to update a part of the web page without refreshing the whole page. AJAX makes web applications richer and more user-friendly. The web context for an Ajax application is usually dynamic. For example, in a data grid, the data and number of rows keep changing at runtime. • JavaScript Events: JavaScript is everywhere on the web today. Many web applications are JavaScript heavy. To test JavaScript, the automated testing framework should be able to trigger JavaScript events in a very convenient way. • Re-usability: Many web applications use the same UI module for different parts of the application. The adoption of JavaScript frameworks such as Dojo and ExtJS increases the chance of using the same UI module for different web applications. A good testing framework should also be able to provide the re-usability of test modules. • Expressiveness: The testing framework should be able to provide users without much coding experience the ability to easily write test code or scripts in a familiar way, like by using a domain specific language (DSL). • Easy to Maintain: In an agile world, software development is based on iterations, and new features are added on in each sprint. The functional tests or user acceptance tests must be refactored and updated for the new features. The testing framework should provide the flexibility for users to maintain the test code very easily. The Selenium web testing framework is one of the most popular open source automated web testing frameworks. It's a ground-breaking framework that offers many unique features and advantages such as browser based testing, Selenium Grid, and "record and replay" of user interactions with the Selenium IDE. However, it has the drawback of being difficult to refactor and maintain. Take the following Selenium test code as an example: setUp("http://www.google.com/", "*chrome"); selenium.open("/"); selenium.type("q", "Selenium test"); selenium.click("//input[@value='Google Search' and @type='button']"); Do you know what UI looks like that the above code is testing assume you are not familiar with Google web site? What does the locator q mean here? What if the XPath
  • 2. //input[@value='Google Search' and @type='button'] becomes invalid due to changes on the web? Most likely, you have to go through the test code to locate the lines you need to update. What if you have tens or hundreds of locators in your test code? Creating the test code using Selenium IDE is easy, but it is difficult to generalize and refactor. Refactoring is a much more tedious and painful procedure than regenerating new test code from scratch because of the use of hard-coded locators and the coupling of locators with test code. Maintaining the code is a hassle because the test code is not structured. The majority of existing web testing tools/frameworks focus on individual UI elements such as links and buttons. Tellurium takes a new approach for automated web testing using the concept of the UI module. The UI module is a collection of UI elements grouped together. Usually, the UI module represents a composite UI object in the format of nested basic UI elements. For example, the Google search UI module can be expressed 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"]) } First of all, Tellurium does not use "record and replay." Instead, it uses the Tellurium Firefox plug-in (Trump) to generate the UI module (not test code) for you. Then you need to create your test code based on the UI module. In this way, the UI and the test code are decoupled. The structured test code in Tellurium makes it much easier to refactor and maintain the code. The composite locator uses UI element attributes to define the UI, and the actual locator (e.g. xpath or jQuery selector) will be generated at runtime. Any updates to the composite locator will lead to different runtime locators, and the changes inside the UI module are localized. The Group locating is used to remove the dependency of the UI objects from external UI elements (i.e. external UI changes will not affect the current UI module for most cases) so that your test code is robust and responsive to changes up to a certain level. Tellurium Overview Tellurium defines a set of Java UI objects, such as InputButton, Selector, List, Table, and Frame, which users can use directly. The basic UI Object works as the base class for all UI objects and it includes the following attributes: 1. uid: UI object's identifier 2. namespace: used for XHTML 3. locator: the locator of the UI object, could be a base locator or a composite locator 4. respond: the JavaScript events the UI object can respond to. The value is a list. All UI Objects inherit the above attributes and methods and many UI objects have their extra attributes and methods. For example, the List object has one special attribute "separator", which is used to indicate the tag used to separate different List child UI elements. Tellurium supports two types of locators: base locator and composite locator. The
  • 3. base locator is a relative XPath. The composite locator, denoted by "clocator", specifies a set of attributes for the UI object and the actual locator will be derived automatically by Tellurium at runtime. The Composite Locator is defined as follows: class CompositeLocator { String header String tag String text String trailer def position boolean direct Map<String, String> attributes = [:] } To use the composite locator, you need to use "clocator" with a map as its value. For example: clocator: [key1: value1, key2: value2, ...] The default attributes include "header", "tag", "text", "trailer", "position", and "direct". They are all optional. The "direct" attribute specifies whether this UI object is a direct child of its parent UI, and the default value is "false". If you have additional attributes, you can define them in the same way as the default attributes, for example: clocator: [tag: "div", value: "Tellurium home"] In the above Tellurium UI module, the "GoogleSearchModule" Container includes a "group" attribute. The group attribute is a flag for the Group Locating Concept. Usually, the XPath generated by Selenium IDE, XPather, or other tools is a single path to the target node such as: //div/table[@id='something']/div[2]/div[3]/div[1]/div[6] No sibling node's information is used here. What is wrong with this? The XPath depends too much on information from nodes far away from the target node. In Tellurium, we try to localize the information and reduce this dependency by using sibling information or local information. For example, in the above google UI module, the group locating concept will try to find the "td" tag with its children as "Input", "Search" button, and "ImFeelingLucky" button. In this way, we can reduce the dependencies of the UI elements inside a UI module on external UI elements to make the UI definition more robust. The Tellurium framework architecture is shown as in Figure 1.
  • 4. Figure 1. Tellurium Architecture. The DSL object parser will parse the DSL object definition recursively and use object builders to build the objects on the fly. The Object Locator Mapping (OLM) is the core of the Tellurium framework and it includes UI ID mapping, XPath builder, jQuery selector builder, and Group Locating. The UI ID supports nested objects. For example, "GoogleSearchModule.Search" stands for a button "Search" inside a container called "GoogleSearchModule". The UI ID also supports one-dimensional and two-dimensional indices for table and list. For example, "main.table[2][3]" stands for the UI object of the 2nd row and the 3rd column of a table inside the container "main".
  • 5. XPath builder can build the XPath from the composite locator, i.e., a set of attributes. Starting with version 0.6.0, Tellurium supports jQuery selectors to address the problem of poor performance of XPath in Internet Explorer. jQuery selector builders are used to automatically generate jQuery selectors instead of XPath with the following advantages: • Faster performance in IE. • Leverage the power of jQuery to retrieve bulk data from the web by testing with one method call. • New features provided by jQuery attribute selectors. The Group Locating Concept (GLC) exploits the group information inside a collection of UI objects to help us find the locator of the collection of UI objects. The Eventhandler will handle all events like "click", "type", "select", and so on. The Data Accessor is used to fetch data or UI status from the DOM. The dispatcher will delegate all calls it receives from the Eventhandler and the data accessor to the connector, which connects to the Tellurium engine. The dispatcher is designed to decouple the rest of the Tellurium framework from the base test driving engine so that we can switch to a different test driving engine by simply changing the dispatcher logic. The Engine is a customized Selenium server with jQuery selector support and a lot of other enhancements to Selenium Core. Tellurium evolved out of Selenium, but the UI testing approach is completely different. Tellurium enforces the separation of UI modules from test code, making refactoring easy. For example, once you defined the Google Search UI module shown above, you can write your test code as follows: type "GoogleSearchModule.Input", "Tellurium test" click "GoogleSearchModule.Search" Getting Started Tellurium Core framework is implemented in Groovy and tests can be written in Groovy, JUnit, TestNG, or pure dsl scripts. Tellurium supports both Ant and Maven. The easiest way to create a new Tellurium test project is to use Tellurium Maven Archetypes. For example, you can use the following Maven command to a Tellurium project based on Tellurium 0.7.0 SNAPSHOT with JUnit 4 support. mvn archetype:create -DgroupId=org.telluriumsource -DartifactId=demo -DarchetypeArtifactId=tellurium-junit-archetype -DarchetypeGroupId=tellurium -DarchetypeVersion=0.7.0-SNAPSHOT -DarchetypeRepository=http://kungfuters.org/nexus/content/repositories/ snapshots After the project is created, you will find the following files pom.xml src src/main src/main/groovy src/main/resources
  • 6. src/test src/test/groovy src/test/groovy/module src/test/groovy/module/GoogleSearchModule.groovy src/test/groovy/test src/test/groovy/test/GoogleSearchTestCase.java src/test/resources TelluriumConfig.groovy The GoogleSearchModule UI module is created using the Trump plugin and the GoogleSearchTestCase is an example Tellurium JUnit Test case. the TelluriumConfig.groovy includes Tellurium project settings and you can customize them to you need. If you want to run the tests in command line, you can use the following Maven command: mvn test Let us look closer at the UI module GoogleSearchModule. public class GoogleSearchModule extends DslContext { public void defineUi() { ui.Container(uid: "Google", clocator: [tag: "table"]) { InputBox(uid: "Input", clocator: [tag: "input", title: "Google Search", name: "q"]) SubmitButton(uid: "Search", clocator: [tag: "input", type: "submit", value: "Google Search", name: "btnG"]) SubmitButton(uid: "ImFeelingLucky", clocator: [tag: "input", type: "submit", value: "I'm Feeling Lucky", name: "btnI"]) } } public void doGoogleSearch(String input) { type "Google.Input", input pause 500 click "Google.Search" waitForPageToLoad 30000 } public void doImFeelingLucky(String input) { keyType "Google.Input", input pause 500 click "Google.ImFeelingLucky" waitForPageToLoad 30000 } } The UI module is a Groovy class, which extends Tellurium DslContext class. The defineUi() method defined a UI module "Google" for the Google search UI with one input box and two search buttons. Two methods are defined for this UI module, i.e., doGoogleSearch for search by clicking the "Google Search" button and doImFeelingLucky for the "I'm Feeling Lucky" button. The actual test class just like regular JUnit 4 class by extending TelluriumJavaTestCase.
  • 7. public class GoogleSearchTestCase extends TelluriumJavaTestCase { private static GoogleSearchModule gsm; @BeforeClass public static void initUi() { gsm = new GoogleSearchModule(); gsm.defineUi(); connectSeleniumServer(); } @Before public void connectToGoogle() { connectUrl("http://www.google.com"); } @Test public void testGoogleSearchWithXPath() { //turn off jQuery Selector gsm.disableJQuerySelector(); gsm.doGoogleSearch("tellurium Groovy Test"); } @Test public void testGoogleSearchFeelingLuckyWithXPath() { //turn off jQuery Selector gsm.disableJQuerySelector(); gsm.doImFeelingLucky("tellurium automated Testing"); } @Test public void testGoogleSearchWithSelector() { //turn on jQuery Selector gsm.useJQuerySelector(); gsm.disableSelectorCache(); gsm.doGoogleSearch("tellurium Groovy Test"); } @Test public void testGoogleSearchFeelingLuckyWithSelector() { //turn on jQuery Selector gsm.useJQuerySelector(); gsm.disableSelectorCache(); gsm.doImFeelingLucky("tellurium automated Testing"); } @Test public void testGoogleSearchWithSelectorCached() { //turn on jQuery Selector gsm.useJQuerySelector(); gsm.enableSelectorCache(); gsm.setCacheMaxSize(10); gsm.doGoogleSearch("tellurium Groovy Test"); }
  • 8. @Test public void testGoogleSearchFeelingLuckyWithSelectorCached() { //turn on jQuery Selector gsm.useJQuerySelector(); gsm.enableSelectorCache(); gsm.setCacheMaxSize(10); gsm.doImFeelingLucky("tellurium automated Testing"); } @Test public void testDump(){ gsm.dump("Google"); } } The initUi() method instantiate the UI module and it provides different test cases for testing "Google Search" and "I'm Feeling Lucky" buttons. As you may notice, Tellurium UI module is agnostic to the locator. XPath is the default locator. If you want to use jQuery selector, you can simply call useJQuerySelector(). The enableSelectorCache() method can be used together with useJQuerySelector() to turn on jQuery selector caching in the Selenium core to improve the test speed further. Apart from that, Tellurium provides a handy method dump() to print out the runtime locator the Tellurium core generates for your UI module in offline mode. Furthermore, you can create a Tellurium TestNG project by using tellurium-testng-archetype. Tellurium UI Model Plugin (Trump) is a Firefox plugin to automatically create UI modules for you. Summary Tellurium introduces a new approach to test web applications based on UI modules. The UI module makes it possible to build locators for UI elements at runtime. First, this makes Tellurium robust and responsive to changes from internal UI elements. Second, the UI module makes Tellurium expressive. A UI element can be referred to simply by appending the names (uid) along the path to the specific element. This also enables Tellurium's Group Locating feature, making composite objects reusable, and addressing dynamic web pages. Tellurium does Object to Locator Mapping (OLM) automatically at run time so that UI objects can be defined simply by their attributes using Composite Locators. Tellurium uses the Group Locating Concept (GLC) to exploit information inside a collection of UI components so that locators can find their elements. It also defines a set of DSLs for web testing. Furthermore, Tellurium uses UI templates to define sets of dynamic UI elements at runtime. As a result, Tellurium is robust, expressive, flexible, reusable, and easy to maintain. Resources 1. Tellurium Project website, http://code.google.com/p/aost 2. Tellurium User Group, http://groups.google.com/group/tellurium-users 3. Tellurium 0.6.0 User Guide, http://aost.googlecode.com/files/ TelluriumUserGuide.0.6.0.pdf