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: 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