When you are using watir-webdriver for web testautomation, you might encounter problems that are not be easy to debug. For example interaction with page elements such as links or buttons that are hidden. Or locating elements in other iframes. One easy way to see what is going on is by interacting with your web browser through the command line!
To make this happen, make sure you have;
- a recent version of ruby installed (1.9.3 or later)
- a recent version of firefox installed
- the ruby gem ‘watir-webdriver’ installed;
gem install 'watir-webdriver'
Now, start the Interactive Ruby Shell…
In this irb, after loading ‘watir-webdriver’, you can start firefox with one command and interact with it right away!
sC-MBP:~ sCblogger$ irb irb(main):001:0> require 'watir-webdriver' => true irb(main):002:0> b = Watir::Browser.new => # irb(main):003:0> b.goto "www.google.com" => "http://www.google.nl/" irb(main):004:0> b.button(:text => /Google zoeken/).id => "gbqfba" irb(main):005:0>
All the functions that are supported by watir-webdriver can be found on the Rubydoc.info website
NOTE: with ruby 1.8.7 or earlier, you’d have to require ‘rubygems’ first before require ‘watir-webdriver’