ABOUT US

|

SUPPORT

|

BLOGS

 

 

DEVELOPER BLOG

 

 

 

 

 

 

 

Testing Dynamic Elements – Having a Plan B

 

Duncan Thomas

 

 

 

 

 

LiquidTest has many varied features and functions. In this blog post I will explain a small but important feature with an example. This feature is a small check box you see at the bottom of your browser when recording a test with LiquidTest, called Dynamic Element.

In this test, I am going to go to Ebay.com.au and I am going to search for a golf driver. After navigating to the site and entering into the search field “golf driver”, eBay does its magic and comes back with a list of results.

However, I want to test an eBay feature and that is the ability to sort the search results and in particular I want to test against the option “Distance: nearest first” (see below).

When you select this option, eBay will load up an internal frame requesting your postal code:

We enter our postal code (in our case, 7000) and then click the “Save” button. eBay then presents our search results in order (closest to furthest). Next, we press the LiquidTest “Finish record” button and LiquidTest writes the following test script:

Although LiquidTest produced a nice and simple to follow test script, there is a problem when I replay the test:

This failure is due to a dynamic element created by the “Distance : nearest to me” option. The elements ID is randomly generated, in this case we can see elements ID in the test script as “v4-1254714420097”. Some frameworks use Dynamic elements as a matter of necessity. With some tools, this can present a headache and a lot of extra work to code the test to allow for this.

However with LiquidTest, we have addressed this issue with a simple to use feature.  Take the above test, this time when I am recording the test and I get to the internal pop up screen with the dynamic element. I will click on the LiquidTest “dynamic element” button before I input our postal code like so:

Selecting the Dynamic Element option in LiquidTest tells LiquidTest that the objects we are testing on this page have either dynamic content or IDs. When selected LiquidTest does not to use the object names or IDs but instead utilizes the full XPath for this element.

The newly recorded test will then be created like this:

The resulting test case uses a full XPath to reference the dynamic element. Because this does not reference specific ID’s or text content, this test will replay without issue.

Whilst we generally prefer to use the IDs for elements on a page as it creates a more robust test, sometimes it is not possible.  When it isn’t possible, it is good to have a backup plan. So that’s why we added the Dynamic Element button, consider it “Plan B”. And best of all, as in this case, you don’t have to use XPaths for every element, just the elements that are dynamic.

 

 

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 (0)

 

 


 

 

No comments yet

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

 

 

Selenium 2 / WebDriver support coming soon to LiquidTest..
Running Selenium Tests from the Command Line
LiquidTest 3.0 with Selenium support ships!
Setting up Atlassian Bamboo to run automated Web 2.0 tests
888 installer builds and 7469 code checkins later LiquidTest 2.0 ships!

 

 

 

 

 

Popular Posts

 

 

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

 

 

 

 

 

Archives

 

 

May 2011 (2) April 2011 (1) November 2010 (2) 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 EOL Announcement - Info
 > LiquidTest Release 3.0! - Available
 > Visual Studio Plugin Released! - Release
 > Cruise Control .NET Integration - Info
 > Automate your Dev/Test Process - Webinar
 > Is manual testing crippling your project? - Blog
 > Testing complex Ajax content - Blog
 
 
   Recently Added Content  
 
 > Run LiquidTest's on Selenium RC/Server - Info
 > Setting up LiquidTest with Maven - Blog
 > Officially Supported Ajax Frameworks - Info
 > Atlassian Bamboo Integration - Tech
 > Setting up LiquidTest with SVN and Hudson - Blog
 > Creating Data-Driven Functional Tests - Blog
 > Reducing Test Maintenance - Blog
 
 
  Copyright JadeLiquid Software - 2014