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.
<config ...>
<option name="ThrowExceptionOnFailingStatusCode" value="false"/>
</config>
<steps>
<invoke description="Load Image" url="missing.gif"/>
<storeResponseCode description="store response code" property="status" />
<verifyProperty description="should be error" name="status" text="404"/>
</steps>
</webtest>
WebTestRecorder