The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Tuesday, 26 January 2010

Watir on Rails

Watir is a tool for user acceptance testing and in general can be used to control a browser to do automated task. Since I am using the standard Rails's testing framework, and I run my tests with rake test, I thought why not to use watir test in a similar way. There is a plugin, Watir on Rails, that integrates Ruby on Rails with Waitr. You only need to run rake test:watir to test your application with rake. The test can be written in a similar way of the other Rails' tests. For instance:



How to use the example:
  1. gem install watir # install watir
  2. script/plugin install git://github.com/chip/watir-on-rails.git
  3. put the file in test/watir or script/generate watir SuccessfulLogin to generate a test
  4. run: rake test:watir
  5. watch the browser doing your job ;-)
  6. Start learning from the cheat sheet:http://wiki.openqa.org/display/WTR/Ruby+Cheat+Sheet


Watir need your web server on, if you are testing a local application, so you should run:

mongrel_rails start -e test # if you are using mongrel

Links:

Watir on Rails - Watir on Rails web page
Watir on Rails at Github
Watir - the official web site

Labels: , ,

1 Comments:

At 8 September 2011 at 05:02 , Blogger Tanin Na Nakorn said...

You can use my gem.

just put

gem 'watir-webdriver-rails' in your Gemfile

Here is how you can use it:
https://github.com/tanin47/watir-webdriver-rails

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home