Yesterday evening I tried to create a prototype using Ruby which should have a simple GUI to insert test data for Watir testscripts.
Shoes is a Ruby library/framework for drawing 2D and web-like UIs which can be compiled into native executables (e.g. *.exe on Windows, *.dmg on MacOS X). Watir is another Ruby library which can be used for automated browser testing. I just thought it would be a good idea to combine this two Ruby libraries to create powerful test environments.
I tried to load the Watir lib in Shoes. Shoes knows the setup block to load libraries via “gem”:
Shoes.setup do
gem 'name >= version'
end
I added further code and tried to run it via Shoes. Then Shoes automatically opens a window which told me that it tries to install Watir. But after a short time I’ve got an error:
hoe requires RubyGems version >= 1.3.1
“Oh no, the wrong RubyGems version…”. So I thougt updating RubyGems would solve the problem.
Console: gems --version
> 1.3.1
Console: gems update --system
> updating... [take a coffee break]
Console: shoes watir_on_shoes.rb
> hoe requires RubyGems version >= 1.3.1
“Arg, still the same error…”. Time to ask my friend Google, but Google just knew the problem, not the solution. Suddenly I remembered the fact that Shoes contains its own Ruby environment… and you might guess that – also a RubyGems distribution. So I found an easy working solution:
Copy all files from
to
%RUBY_HOME%\lib\ruby\gems\1.8\gems\rubygems-update-1.3.4\lib\rubygems
%SHOES_HOME%\0.r1134\ruby\lib\rubygems
That fixed the problem and Watir was properly installed. Maybe you are interested in my simple prototype:
Shoes.setup do
gem 'watir >= 1.5.6' # might be out of date
end
require 'watir'
class ShoesWatirTest < Shoes
url '/', :index
def index
stack :margin => 20 do
title "Watir-test"
flow do
para "URL:"
@search = edit_line
button "GO!" do
@ie = Watir::IE.new
@ie.goto "http://www.google.de/"
@ie.text_field(:name, "q").set @search.text
@ie.button(:name, "btnG").click
para @ie.text
end
end
end
end
end
Shoes.app :width => 400, :height => 800


