Canoo Webtest WebTest Canoo

Extension Step storeResponseCode

Description

Provides the ability to store the HTTP Response Code value for later checking.

Normally, you can safely ignore HTTP response codes while using Canoo WebTest. Simply try to use web resources normally in your tests. Any which can't be retrieved normally (i.e. which don't return HTTP status code of '200') will cause your steps to fail.

Sometimes however, it is useful to retrieve the response code, e.g. to distinguish between server errors (typically code '500'), missing resources (code '404') and security issues (typically codes 401 or 403). Or perhaps to verify the messages which these kind of errors display to the user. This step allows you to achieve this requirement. In order for Canoo WebTest to not report non-'200' status codes as an error, you need to set an option (see below).

Parameters

property
Required? yes
The name of the property in which to store the Response Code value.
description
Required? no
The description of this test step.
propertyType
Required? no, default is the "defaultPropertyType" as specified in the "config" element is used.
The type of the property in which to store the retrieve value. Either "ant" or "dynamic".

Details

NOTE: the ThrowExceptionOnFailingStatusCode option setting in the config element needs to be set to false. You don't need to set this option if you want to test for return status codes of '200' but if the step doesn't fail, you already know it is a '200' status code.

storeResponseCode Example
<webtest name="httpResponseCode: confirm error page">
    <config ...>
        <option name="ThrowExceptionOnFailingStatusCodevalue="false"/>
    </config>
    <steps>
        <invoke description="Load Imageurl="missing.gif"/>
        <storeResponseCode description="store response codeproperty="status" />
        <verifyProperty description="should be errorname="statustext="404"/>
    </steps>
</webtest>

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