Canoo Webtest WebTest Canoo

Properties

WebTest knows about two kinds of properties, ant properties and dynamic properties. You typically select which kind you want to store into using the propertyType attribute of the storeXXX steps or by setting a defaultpropertytype in your config. You select which kind you want to read from using the ${} or #{} syntax. This section explains additional details about these two kinds of properties.

Ant Properties

${} properties are normal ANT properties. Given ANT's philosophy of a declarative build process, these are normally immutable. I.e. once you set a property its value normally can't be changed. ANT property values are typically determined at the start of an ant target. They are available to both ANT tasks and WebTest steps.

Dynamic Properties

#{} properties are only available (currently) to webtest steps. They are dynamic - you can use the same property and set it to different things throughout your tests. #{} properties support very simple expressions and there is support for accessing scripting variables under special circumstances. Property values are determined at the moment of use.

Nested Properties Expansion

Contrary to normal Ant execution (see Ant's enhancement issue), nested properties are evaluated during the execution of a WebTest. This means for instance that something like ${myProp#{counter}} will be evaluated just like ${myProp1} if the current value of the dynamic property counter is 1. Both nested Ant properties and dynamic properties are evaluated.

Converting Properties

You can happily swap between them using storeProperty by setting the propertyType attribute to the appropriate value.

Examples showing property type conversion
<steps>
..
    <-- assumes defaultpropertytype not set in config -->
    <storeProperty
        description="convert dynamic to Ant"
        name="ant_prop"
        propertyType="ant"
        value="#{dyn_prop}"/>
    <storeProperty
        description="convert Ant to dynamic"
        name="dyn_prop"
        value="${ant_prop}"/>
    <storeProperty
        description="convert combination to dynamic"
        name="dyn_prop2"
        value="text_mixed_with_${ant_prop}_and_#{dyn_prop1}"/>
..
</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