Canoo Webtest WebTest Canoo

Extension Step storeLength

Description

Stores a length value for the response (or part of the response) into a property. This is useful when you don't care about the content within a response but wish to ensure that at least the length hasn't changed from some expected value. Supports content filters such as lineSeparatorFilter and replaceFilter to allow you to filter out content that you are not interested in and the table locator step if you are interested in content within a table.

Parameters

property
Required? yes
The target property name.
description
Required? no
The description of this test step.
htmlId
Required? no
The id of an HTML element. If present, processing will be limited to this element. Will be ignored if a nested table step is used.
propertyType
Required? no, default is the "defaultPropertyType" as specified in the "config" element is used.
The target property type. Either "ant" or "dynamic".
xpath
Required? no
An XPath expression identifying an HTML element. If present, processing will be limited to this element. Will be ignored if htmlId is set or if a nested table step is used.

Nested Parameters

step
Required? yes
A webtest step.
table
Required? no
To locate a specific cell in a specific table on the page.

Details

The following example illustrates how to use the storeLength step (illustrating the use of the nested table locator step):

storeLength example
<webtest name="storeLength: storeLength with table">
    <config ... />
    <steps>
        <invoke description="tableTest mode of the test servlet"
                url="${start.page}?mode=tableTest"/>
        <verifyElement description="table expectedtype="tabletext="test"/>
        <storeLength property="lengthTable">
            <table description="content should be 'row:column'row="1column="1id="test"/>
        </storeLength>
        <verifyProperty description="content should be '1:1' so length should be 3name="lengthTabletext="3"/>
    </steps>
</webtest>

One of the ways to calculate the length value (so that you can write the test) is to use a dummy value (e.g. '999') and then run the test. Then when it fails it will tell you what it was expecting. Simply copy that value into your test. Eventually we may store length values in a file and populate the file for you the first time the test is run or we may have a tool (e.g. Mozilla plug-in or one of the other recorder tools) to pre-calculate length values for you.

See also: the verifyContent, storeDigest, lineSeparatorFilter, replaceFilter, tagStripper and contentStripper steps.

news

Latest build: development
Posted: 19-Jul-2016 17:36

WebTest 3.0 released, featuring upgrades to Java 5, Groovy 1.6, and HtmlUnit 2.4.
The release includes support for maven integration, IDE-integration like for unit tests, capturing of background JavaScript errors, new steps for mouseOver and mouseOut events, better parallel execution of tests and - as usual - lots of handling improvements.
Posted: 5 March 2009

WebTest @ JavaOne
Dierk König presented "Functional testing of web applications: scaling with Java" on Wed May 7, 13:30 at JavaOne 2008 in the Tools and Scripting Languages track.
Posted: 8 May 2008

New WebTest screencast available:
Data Driven WebTest
Posted: 13 November 2007

First WebTest screencast available:
Creating a first Webtest Project

Extend WebTest with Groovy! Groovy in Action is available in every good bookstore.
Groovy in Action
Posted: 29 January 2007