Webtest WebTest GitHub Home

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.