Skip to end of metadata
Go to start of metadata


While the general ideas of this script are still valid and useful, this script is not working properly. The reason for this, is that when getting the source code of a page (via a browser, selenium or javascript), closing slash of self-closing tags is removed. This means valid pages containing self enclosing tags will not be validated correctly (the are possibly other valid markup that will be changed when retrieving the source).

I have currently been unable to find a solution to this problem (it becomes complicated due to the need of logging in, having very javascript heavy pages, generated markus and AJAX calls).

Instead of this script, go to Quality Assurance. On the bottom of that page, links are given to scripts able to validate static HTML pages.


Small program to validate CollectionSpace pages against the XHTML 1.0 Strict standard. The program uses a combination of Selenium Remote Control (RC), a custom Java program and optionally Xvfb (X Virtual Frame Buffer) to login to the nightly CollectionSpace server, grab the source from a page, and the pass it to the online W3C validator. The script is triggered and results reported using the Bamboo server.


The DTD validator consists of three distinct parts:

  • Xvfb: This is optional. It allows the script to run headless (ie. without the need of a screen). It is an X server that runs entirely in memory, and consequently allows Selenium to run in an environment without a screen attached.
  • Selenium server: Selenium is a program for automated browsing, usually used for acceptance testing. The way this is used, is by having a selenium server running, and a client script connecting to it. The client script contains the actions that should be done in the server, while it is the servers job to actually carry out this job.
  • Custom Selenium Client: This is the client side of selenium. It has been written specifically for CollectionSpace, and works by logging in to CollectionSpace, navigating to the page(s) that should be validated and grabbing the source code. Once this has been done, the script loads the w3c validation page (, enters the source to validate, and reports the result to the log.





1.5 or higher

Google Chrome

7 or higher




The script is available via svn on: <REPOSITORY PATH HERE>


Manual Usage without Xvfb

The ant script automatically starts the selenium before execution and stops it afterward. To manually run the program, simply run:

This will compile the program, start the selenium server, run the validation and stop the selenium server. The return code of the program will be 0 if successfully validating. For each failed page, the results from the W3C validator are printed to stdout.

Manual Usage with Xvfb

If you do not have a screen available, or simply do not want the validator to take up screen space, you can use Xvfb. The procedure for this is slightly more complicated, but not much. First make sure you have the Xvfb installed, then start the server by executing the following command in the xvfb dir:

After this is done, you should be ready to run the validator. Consider doing this in another console, so the output of the two programs wont be mixed up. While this is not a particular problem, it might be confusing, and make it harder to see which program potential errors and messages are from. To run the validator first set the DISPLAY environment variable to :1, to ensure that selenium will run in the Xvfb server. Then execute the validator script. These steps will be done, by running the following commands from the java dir:

Once the tests are done, you can stop the Xvfb server, by running the following command in xvfb:

Automating the Process Using Bamboo

This entire process can be captured in a Bamboo task, which is the setup we are using in CollectionSpace. This is done like follows:

  • In the Builder tab, set:
    • Builder: ant
    • Build File: build.xml
    • Target: clean run
    • System Environment Variables: DISPLAY=:1
  • Under Pre Build Commands:
    • Command: <path-to-xvfb>/xvfb-server start
  • Under Post Build Commands:
    • Command: <path-to-xvfb>/xvfb-server stop

Set the Task and Project Name, Reporting and Triggering as desired (We run the program after each nightly rebuild).

  • No labels