Here is a piece of code that doesn't work in FireWatir 1.6.2:
require 'watir'
Watir::Browser.default = 'firefox'
browser = Watir::Browser.new
browser.goto("http://www.google.com")
searchform = browser.form(:xpath, "//form[@name='f']")
puts "Searchform is #{searchform.to_s}"
You will get this output:
>ruby firewatirbug.rb
C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:1403:in `method_missing': stack level too deep
(SystemStackError)
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
htmlelements.rb:75:in `locate'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:1012:in `exists?'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:965:in `assert_exists'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:1403:in `method_missing'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
htmlelements.rb:75:in `locate'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:1012:in `exists?'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:965:in `assert_exists'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:1403:in `method_missing'
... 9453 levels...
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:1012:in `exists?'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:965:in `assert_exists'
from C:/Ruby/lib/ruby/gems/1.8/gems/firewatir-1.6.2/lib/firewatir/
MozillaBaseElement.rb:1097:in `to_s'
from firewatirbug.rb:10
Now, I found something on the net that says that this bug was fixed
way back in 2007:
http://code.google.com/p/firewatir/issues/detail?id=36
So is it fixed, did it recur, is my installation broken, ???
I've coded around it using element.attribute_value() but I really
wanted to use the xpath instead.
--Kevin White