Calling Raakt from the command line

This script shows how Raakt can be used in a simple Ruby script to test a remote web page.

First, make sure you have installed Raakt (follow the installation instructions if necessary).

Then, install the Mechanize library (it will be used to fetch remote web pages) by opening a command prompt and type:

gem install mechanize

Now, open your favourite text editor and paste the following code into it:

require 'rubygems'
require 'mechanize'
require 'raakt'
#Parse command line url argument to get URL
url = ARGV[0]
#Set up mechanize agent
agent =
# Get the page
page = agent.get(url)
# Set up the RAAKT test and pass html and headers
raakttest =, page.header.to_hash)
#Run all checks and print result to the console
result = raakttest.all
if result.length > 0
  puts "Accessibility problems detected:"
  puts result
  puts "No measurable accessibility problems were detected."

Save the file as test.rb, navigate to the folder where you saved the file and type:

ruby test.rb

This will fetch the start page and run all the Raakt tests on it.

Interpreting the result

Output will look similar to below. Each error message is reported as

Issue identifier: Issue text

For a list of error messages and their explanations see the Raakt test documentation.

Accessibility problems detected:

ambiguous_link_text: One or more links have the same link text (' H
ome'). Make sure each link is unambiguous.

field_missing_label: A field (with id/name 'q') is missing a corresponding label element. Make sure a label exists for all visible fields.

wrong_h_structure: Document heading structure is wrong.
examples/commandline.txt · Last modified: 2010-08-29 15:49 by peterkz
Recent changes RSS feed, Powered by DokuWiki