Canoo Webtest WebTest Canoo

Extension Step verifyLinkedContent

Description

Verify all selected links on a page for existence and, optionally, mime-type.

This step provides a mechanism to verify the availability of the resources linked from a page. The step tries to fetch all the resources referenced on the page that the xpath attribute selects. With this step, the availability of any kind of resources can be ensured, such as images, css stylesheets, linked javascripts, ...

Further, the step can verify that the webserver provides the resources with the correct mime-type.

Parameters

xpath
Required? yes
The links to checks
accept
Required? no, default is Accepts anything.
Type and subtype that the answer must have, in the classical mime-type notation.
description
Required? no
The description of this test step.

Details

The attribute accept follows a subset of the description of the http-accept header in RFC 2616, simplifying it where possible:
The attribute value takes one or more media-range, separated by a semi-colon.
A media-range is a pair of mime type and subtype separated by a slash. The special subtype * accepts all of subtypes of the named type, and the special media-range */* accepts any mime-type.

The most simple usage of <verifyLinkedContent> is to make sure that the server returns all resources. Note that the simple xpath selects the resources to verify.

Verify the existence of all stylesheet
<verifyLinkedContent
  xpath="/html/head/link[@rel='stylesheet']/@href"
  />

In a middle level, <verifyLinkedContent> can also enforce the mime-type returned by the server.

Verify the existence and the mime-type of all stylesheet
<verifyLinkedContent
  xpath="/html/head/link[@rel='stylesheet']/@href"
  accept="text/css"
  />

In an example of advanced usage, the xpath selects all images in the page and makes sure that the images are either gif or png.

Verify the existence and the mime-type of all images
<verifyLinkedContent
  xpath="//img/@src | //input[@type='image']/@src"
  accept="image/gif;image/png"
  />

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