FireWatir bug using exists? on a form element with xpath

29 views
Skip to first unread message

Kevin White

unread,
Mar 5, 2009, 3:48:56 PM3/5/09
to Watir General
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

Kevin White

unread,
Mar 5, 2009, 4:44:20 PM3/5/09
to Watir General
Apologies, that code just demonstrates that xpath isn't working right.
I was trying to use .exists? in my code, but the example just is to
demonstrate that the xpath doesn't work at all. If you try to
do .exists? on a form element using xpath, it fails the same way.

--Kevin

Angrez Singh

unread,
Mar 6, 2009, 12:36:09 AM3/6/09
to watir-...@googlegroups.com
Nice catch, there was a spelling mistake while locating the form using xpath. Fixed it. Will let you know when I check in the code

- Angrez
Reply all
Reply to author
Forward
0 new messages