Finding a form by xpath in Firewatir causes ‘Stack Level Too Deep’

If in a firewatir script you look for a form using xpath, you’ll get the following output:


SystemStackError: stack level too deep
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/htmlelements.rb:72:in `locate'
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:1012:in `exists?'
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:965:in `assert_exists'
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:1403:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/htmlelements.rb:75:in `locate'
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:1012:in `exists?'
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:965:in `assert_exists'
from /Library/Ruby/Gems/1.8/gems/firewatir-1.6.2/lib/firewatir/MozillaBaseElement.rb:1403:in `method_missing'
... 4235 levels...

Known bug, apparently:

http://groups.google.com/group/watir-general/browse_thread/thread/8ef42aef5dae69df

Get around it by using :id or some other locator. Here’s some code to replicate the above:


require "FireWatir"
include FireWatir
@browser = Firefox.start("http://www.google.com")
@browser.form(:xpath, "//form").exists?

This entry was posted in Automated Testing, WATIR and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>