httpresource

description

Obtain information about a HTTP resource. All information taken from the web server's response headers.

Example headers (and values) which might be available to you are;

  • Date: Wed, 18 Feb 2009 12:19:15 GMT
  • Server: Apache
  • Last-Modified: Mon, 22 Jan 2007 13:18:34 GMT
  • Etag: "ff805-57c-427a0e6023e80"
  • Accept-Ranges: bytes
  • Cache-Control: max-age=2592000
  • Expires: Fri, 20 Mar 2009 12:19:15 GMT
  • Content-Type: image/gif
  • Content-Length: 1404 Age: 163

required extensions

  • include by Jerry Qian, Robert Zimmermann, Paul Hammant, Andy Lawrence and Alex.

Please note that the examples below also make use of assertEquals for comparisons and datadriven for data persistence however neither of these are required by the httpresource extension itself.

features

  • Each header name/value pair can be stored to a regular Selenium variable.
  • Full response data is loggable to the INFO window for insepection.

example of use

Testing for image file changes.

First of all you'll need to get some information about the image from the web server. You can do this from a point in your main test script or from a standalone test script dedicated to this purpose. E.g.

Command Target Value
getHTTPResource http://www.openqa.org/shared/images/logo.gif  
logHTTPResourceResponse    

If run within the IDE the above script would log all response header text to the INFO window and you could examine each header value from there. The header of interest in this example is Etag which is computed from the Last-Modified header value and the Content-Length header value, making it a decent indicator of whether a resource has changed in any way.

Example: httpresourcetest_inspectimage.html

Now that this image's Etag header value is known it can be saved for comparison later as part of a test script.

Example: openqa_logo_etag.xml

The next step is to compare the image in the system under test with the saved image Etag value. To do this just load the saved Etag data using datadriven, use httprequest to get the live image Etag then compare the two values using assertEquals.

Example: httpresourcetest_compareimage.html

limitations

  • You might notice that httpresourcetest_compareimage.html uses the command storeHTTPResourceResponseHeaderValue provided by the httpresource extension. Be aware that some response header names are hyphenated. Attempts to create a Selenium variable from a hyphenated response header name won't work - you won't be able to retrieve it. See the example httpresourcetest_hyphenated_headers.html for a simple demonstration on dealing with such header names, if that's what you need to do.

help & support

My email address is within the comments of the datadriven extension's Javascript. You may contact me for help and support with this extension but please (since I have a real life to live), only after you've done the following:

  1. Read all of the above documentation carefully and thoroughly.
  2. Exhausted all possible means at your disposal of resolving the issue yourself.
  3. Read all of the above documentation carefully and thoroughly again.
  4. Made further efforts to resolve the issue by yourself.
  5. Searched the Selenium IDE forums for similar issues to your own in an attempt to resolve your issue.

I'll welcome your mail if you've done the above and absolutely require help. In this case;

  1. Keep it relevant to Selenium and the datadriven extension.
  2. It's a shame this has to be said but please exercise some courtesy and professionalism. Being rude and abrupt won't get you anywhere other than my spam senders list.
  3. Please be detailed with regard to what you're trying to achieve.
  4. Please be detailed with regard to the problem you're facing and the actual outcome you're experiencing.
  5. Provide as many relevant resources and code as possible. E.g. all user extensions files in use, your test scripts and test data. Please note that I am not interested in your employer's actual data, active logins or anything of this nature. Any mails containing what I suspect to be material sensitive to your employer will be returned with a polite request to re-read these notes. Repeat offenders will be permanently added to my spam senders list.
  6. Finally, when you've done all that... Please be patient. You will get a response.

revision history

  • 2009-02-19: v0.1: Initial version.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.