|
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.
|