Canoo Webtest WebTest Canoo

General Step config

Description

This is a nested task of webtest and is used to configure the target host system to use for a particular webtest and several other features such as reporting of test results and printing of debug information.

The <config> element is a nested element of webtest and is used to configure the target host system to use for a particular webtest and several other feature like reporting of test results and printing of debug information.

Since the <config> element can contain so many different attributes, the description of the attributes is split over many tables.

The first table describes the default URL parameter.

basepath
Required? Yes
Defines the constant base path used to construct request URLs, e.g. "shop" can be considered a basepath in "http:/www.myhost.com/shop/productlist" and "http:/www.myhost.com/shop/checkout".
host
Required? No, default is "localhost"
Defines the hostname to use for executing requests, e.g. "localhost" or "www.myhost.com".
port
Required? No, defaults is "80"
Defines the port number to use for executing requests, e.g. "8080".
protocol
Required? No, defaults is "http"
Defines the protocol to use for executing requests. "http", "https", and "file" are currently the only supported protocols.

The next table describes the attributes responsible for WebTest's reporting and logging. These attributes define if and where WebTest store logging information. Actual reporting is usually performed by xsl transformation after the test complete.

resultfile
Required? No, default is "results.xml".
Deprecated: not used anymore.
resultpath
Required? No, default is the subdirectory "webtest-results" of the project base directory.
Defines the resultpath of saved responses (for example last response).
saveprefix
Required? No, default is "response"
Sets the name to use if the current response received from the target host is to be saved into a file. A unique id will also be appended after the prefix.
saveresponse
Required? No, default is "false"
Defines whether the last response received from the target host is saved into the file "<saveprefix><uniqueId>.html". saveprefix is the value set in the <saveprefix> config element.
uniqueId is a timestamp at the time the file is saved.
This is especially helpful for debugging your tests.
summary
Required? No, default is "false"
Defines whether a summary reports all test steps, their parameters and execution times on successful completion of the test.

The next table describes the webtest's behaviour when encountering failures and errors.

errorproperty
Required? No
Specifies the name of an ant property which is set to true if the execution of the current <webtest> stops if a program error (unhandled exception) is encountered in one of the test steps. When using this property, set "haltonerror" to "false". Then check the ant property after performing all of your tests and if set fail. This allows your tests to continue running even if some experience execution errors (allowing you to catch multiple errors with one test run) but still ultimately fails the build if anything went wrong.
failureproperty
Required? No
Specifies the name of an ant property which is set to true if the test fails. When using this property, set "haltonfailure" to "false". Then check the ant property after performing all of your tests and if set fail. This allows your tests to continue running even if some fail (allowing you to catch multiple errors with one test run) but still ultimately fails the build if anything went wrong.
haltonerror
Required? No, default is "true"
Determines if the execution of the current <webtest> stops if a program error (unhandled exception) is encountered in one of the test steps. An ANT BuildFailed exception will be raised if it is set to "Yes". This will terminate the execution of the ANT script.
Setting the option to "false" will stop the execution of the current <webtest> but continues with the next ANT task, e.g. another <webtest>.
haltonfailure
Required? No, default is "true"
Determines if the execution of the current test halts if a failure of one of the test steps is detected, e.g. a <verify...> test did not pass. Even when set to "false" all of the trailing <step>s of the current <webtest> will be skipped but processing will continue with the next <webtest>.

The next table groups miscellaneous configuration options.

autorefresh
Required? No, default is "false"
Specifies whether the client should automatically follow page refresh requests (html: <meta http-equiv="refresh" ...>).
If set to "true" or "false", this indicates if refresh requests should be followed or not. If set to an integer value only refresh request with a delay less or equal to the specified value will be executed.
defaultpropertytype
Required? No, default is "dynamic",
Determines the default storage used for properties. If set to "dynamic", webtest dynamic properties are used. If set to "ant", properties are stored as ant variables. If set to "antstrict", ant properties are used but normal ant immutability is respected, i.e. if a property is already set, then it won't be over-written.
When setting this attribute to "ant" or "antstrict", the #{propName} syntax allows late binding to ant properties whereas the ${propName} syntax remains supported with normal binding.
If using ant properties to store webtest properties, the values of properties persist across <webtest> tasks but you run the risk of name clashes with other tasks using ant properties.
If using repeat steps, avoid using "antstrict" for this setting if you need access to the repeat loop counter value. The repeat loop will execute as normal but the #{count} property will remain unchanged once set.
showhtmlparseroutput
Required? No, default is "false"
Defines that the JTidy output of parsing resulting HTML pages shall be shown. If enabled, the generated errors/warnings are collected as test step parameters and written into the report file. The output is also written to stdout. The parser output can be used to detect invalid HTML code in a particular page, unbalanced elements or invalid nesting of elements (e.g. <form> and <table>).
Since the parser can generate a lot of warnings and these warnings need to be manually analyzed, it is recommended to enable this option only on demand, e.g. to initially verify the correctness of an HTML page or if a particular test case does not work (e.g. a button can not be found in a page).
timeout
Required? No, default is "300"
Defines the timeout value in seconds for both connection and socket.
The connection timeout is the maximum allowed time until a connection is etablished. The socket timeout is the timeout for waiting for data.
A timeout value of zero is interpreted as an infinite timeout.
config
<webtest name="Visit the shop on myhost">
  <config
    host="www.myhost.com"
    port="8080"
    protocol="http"
    basepath="shop"
    summary="true"
    saveresponse="true"
    resultpath="/tmp/results"
  >
    <header name="User-Agentvalue="Mozilla/4.0"/>
    <header name="Accept-Languagevalue="de-ch"/>
  </config>
  ...
</webtest>

The previous test code example will create URLs with the following prefix: "http://www.myhost.com:8080/shop/".

Parameters

description
Required? no
The description of this test step.

Nested Parameters

header
Required? no
Specify http headers by name and value
option
Required? no
Tweak the underlying web client options/settings

news

Latest build: R_1705
Posted: 14-May-2008 13:13

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

WebTest 2.6 released, featuring upgrades to Ant 1.7, Groovy 1.5.4, and HtmlUnit 1.14.
The release includes support for data-driven testing, testing of drag-and-drop, advanced AJAX support, high-concurrency testing and reporting, real-time monitoring, and - as usual - lots of handling improvements.
Posted: 18 March 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