Canoo Webtest WebTest Canoo

Extension Step verifyContent


Compares the current response with an expected file. Supports content filters such as lineSeparatorFilter and replaceFilter and the nested table step.


Required? yes
The file to compare to
Required? no
The description of this test step.
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.
Required? no
The diff mod to use for comparison. Possible values are "auto" (the default, uses "text" or "bin" depending on the type of the content to compare), "text" (performs a unified diff like diff), "bin" (compares byte per byte and displays differences in hex format), and "regexPerLine" (each line of the reference file is a regex that should match the actual content).
Required? no, default is true
Indicates that when reading referenceFile that the content should be filtered.
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

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


The following example illustrates how to use the verifyContent step (illustrating the use of the nested regular expression replacement filters to remove dynamically changing content which would otherwise make the comparison fail):

verifyContent example
<target name="testVerifyContentRegex">
    <property name="variableNumberRegexvalue="(?&lt;= )[0-9]+(?= time)"/>
    <webtest name="verifyContent: verifyContent with regex replace">
        <config ... />
            <invoke url="visitCount.jsp"/>
            <verifyContent referenceFile="verifyContent/expectedVisitCount.html">
                <replaceFilter regex="(as at ).*(&lt;/title&gt;)replacement="$1[DATE REMOVED]$2"/>
                <replaceFilter regex="${variableNumberRegex}"/>
            <invoke description="load page again - content will changeurl="visitCount.jsp"/>
            <verifyContent referenceFile="verifyContent/expectedVisitCount.html">
                <replaceFilter regex="(as at ).*(&lt;/title&gt;)replacement="$1[DATE REMOVED]$2"/>
                <replaceFilter regex="${variableNumberRegex}"/>

If the files differ, you should see a message indicating the differences in your logs (depending on what logging levels you have set), for example:

verifyContent error
**** The last response and the expected file 'expected/expectedDummyWithChanges.html' differ.
The differences are:
[3] >> <title>Dummy</title>
[3] << <title>Dummy with Changes</title>
[7] >> Dummy page
[7] << Altered Dummy page

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


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