Using Raakt in Watir

Watir is a free, open-source functional testing tool for automating browser-based tests of web applications. It is pronounced “water”. Watir is a family of Ruby libraries. They support Internet Explorer on Windows, Firefox on Windows, Mac and Linux, Safari on Mac, Chrome on Windows.

Since Watir drives an instance of a web browser it is very easy to test pages that use AJAX or other techniques to dynamically render content.

To use Raakt in Watir, first install the Raakt gem.

Adding basic accessibility tests in Watir for is easy (this example uses Internet Explorer):

require 'watir'
require 'raakt'
require 'test/unit'
 
class TC_myTest < Test::Unit::TestCase
 
  attr_accessor :ie
 
  def setup
    @ie = Watir::IE.start("http://www.peterkrantz.com")
  end
 
  def teardown
    @ie.close
  end
 
  def test_startPagePassesBasicAccessibility
    #set up the accessibility test
    raakttest = Raakt::Test.new(@ie.document.body.parentelement.outerhtml)
 
    #run all tests on the current page
    result = raakttest.all
 
    #make sure raakt didn't return any error messages
    assert(result.length == 0, result)
  end
end