Monday, May 25, 2009

Playing with Watir

Past few days I have been playing with using Watir in my current project. I bet it has been fun. Watir gives this awesome power for automated testing. Many would argue why not Selenium for that matter. There were few challenges using Selenium:

Frames and popup supportEasyHas problems
API for database connectivityEasyDoesnt have API support
Multi language (non-ascii character)supportEasyNo
RecorderYesOnly for FF
Integration with RspecEasy to create a test suite. See example below
Cross domain supportYesNo
Ajaxified responsesYesDifficult

One of the fun part was attaching your browser instance to your IRB. The examples here is self sufficient explanation. If not, then watir-console is theie for rescue.

Not to forget the Excel Interface Class, which we used to download an excel report (as part of our project) and match the values against DB records.

The rspec task to run the tests as a suite and also lets you connect to environment specific database:

desc "Run all watir tests "
namespace :spec do do |t|
ENV["WATIR_ENV"] = ENV['env'] ? "#{ENV['env']}" : "development"
t.spec_files = FileList['test/integration/watir/*_spec.rb']
t.spec_opts = ["-fh > public/watir_results.html"]

From the command prompt you could run:

>> rake spec:watir (runs and connects against development database)
>> rake spec:watir env=qa (runs and connects against qa database)

Lately, a lot of progress has been made on Watir Recorder

No comments: