DEVELOPER  BLOG

 

 

 

 

Protecting investment: Tests that do not break with page changes

 

Anthony Scotney

 

 

 

 

 

One of the critical failings of automated web application testing comes when existing (previously recorded) test cases break due to changes with web infrastructures and back-end changes. Organizations invest significant time and money in building test infrastructures and recording automated tests, to find that far too often tests break when changes are made to minor content or page structure.

Why Tests break:

Simply speaking the most frequent reason for test cases breaking in modern testing frameworks (assuming you are past the evils of First Generation test frameworks) is due to the addressing of elements within a target page. More often than not the element addressing is too granular. What we mean by “granular” is that page elements (nodes) are addressed (located) in a very page structure specific manner. Almost all testing products claim to write succinct and robust test cases but in reality nothing is further from the truth. Test cases can easily be fragile.

How LiquidTest handles page changes:

From day one, the LiquidTest development team was well aware of the “achilles heel” of Second Generation testing frameworks. Generally speaking, the LiquidTest recording element locator tries to build test cases that will not break with minor or even major page changes. The basic searching algorithm (without getting too technical) utilizes the following; unique text, ID, name, value and lastly XPath’s to locate elements. The reason the XPath is the last item we use (only if forced), is because it is the most granular and more likely to break upon page structure changes.

Example pages:

We will demonstrate how LiquidTest handles the following two page variations;

Result!

The following is the LiquidTest recorded test case, for both of the HTML page variations:

public void myTest() {
    browser.load("http://localhost/test.html");
    // Check the "Hello World" is on the page
    assertEquals("Hello World", browser.getValue("Hello World"));
}

The test case records exactly the same on both pages! This demonstrates that the test case will not break between page layout changes or changes to the page style (or content). The content addressing plays an important role in making sure test cases are robust and do not break between layout and style changes.

Does the test case replay?

Why?

It all comes down to smart robust addressing.

STOP! But what if I want page changes to be noticed? Simple answer: Just assert the structure of the document, using the DOM inspector to add assertions.

 

 

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • DZone
  • TwitThis
  • email
  Comments (2)

 

 


 

 

Comments:

  1. Hello. I think the article is really interesting. I am interested in reading more. How soon will you update your blog?

    Comment by GarykPatton on June 16, 2009 at 9:37 am

  2. Gary, we plan on updating the blog regularly. Watch this space. There is much more to come!

    Comment by Anthony Scotney on June 25, 2009 at 1:18 am

Add Comment..

 

 

About this blog..

 

This is an informal place for the team at JadeLiquid to discuss software, the rotation of the earth and other things usually discussed in the JadeLiquid corridors.

 

 

 

Subscribe: By Feed  By Email

 

 

 

 

 

Categories

 

 

JadeLiquid

LiquidTest

 

 

Software Testing

 

 

WebRenderer

 

 

 

 

Recent Posts

 

 

Setting up LiquidTest with Maven
Knowing your Enemy - Foundations of LiquidTest
Eclipse and LiquidTest UI Introduction
Testing Dynamic Elements – Having a Plan B
Setting up LiquidTest with Subversion and Hudson (Continuous Integration) part 2

 

 

 

 

 

Popular Posts

 

 

Testing complex Ajax content
Protecting investment: Tests that do not break with page changes
One tool to rule them all - Reducing team division
Creating Data-Driven Functional Tests with LiquidTest
Setting up LiquidTest with Subversion and Hudson (Continuous Integration) - part 1
Is manual testing crippling your development project?
Setting up LiquidTest with Subversion and Hudson (Continuous Integration) part 2
Testing Dynamic Elements – Having a Plan B
Eclipse and LiquidTest UI Introduction
Knowing your Enemy - Foundations of LiquidTest

 

 

 

 

 

Archives

 

 

March 2010 (1) February 2010 (1) November 2009 (1) October 2009 (1) September 2009 (2) August 2009 (1) July 2009 (1) June 2009 (1) April 2009 (1) March 2009 (1)

 

 

 

 

 
   News / Events

 

 > LiquidTest Release 1.0.17 - Available Now!
 > Automate your Dev/Test Process - Webinar
 > LiquidTest Best Practices - Webinar
 > Next Generation Agile Testing - Webinar
 > Is manual testing crippling your project? - Blog
 > Reducing team division - Blog
 
 
   Recently Added Content  
 
 > Eclipse and LiquidTest UI Introduction - Blog
 > Setting up LiquidTest with SVN and Hudson - Blog
 > Creating Data-driven Functional Tests - Blog
 > Testing complex Ajax content - Blog
 > Reducing Test Maintenance - Blog
 > Testing Dynamic Elements - Having a Plan B - Blog
 
 
  Copyright JadeLiquid Software - 2010