jarib / celerity

This project is no longer maintained.
http://celerity.rubyforge.org/
GNU General Public License v2.0
206 stars 38 forks source link

getRows is undefined for Table Element #16

Closed gonzalogtesta closed 14 years ago

gonzalogtesta commented 14 years ago

When verifying if a table exist or if it's visible, the following error message is returned from jruby:

C:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/celerity-0.7.9/lib/celerity/ elements/table.rb:25:in locate': undefined methodgetRows' for #<HtmlTableData Cell:0x1c26db4> (NoMethodError) from C:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/celerity-0.7.9/ lib/celerity/element.rb:174:in assert_exists' from C:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/celerity-0.7.9/ lib/celerity/element.rb:186:inexists?'

jarib commented 14 years ago

Could you provide some example HTML that will reproduce the error?

gonzalogtesta commented 14 years ago

Here is the Ruby code:

http://paste-it.net/public/i76338b/

And here is the HTML code:

http://paste-it.net/public/lbc0df9/

jarib commented 14 years ago

Thanks. The problem is that your XPath finds a a td element, but table() expects a table element. I will add a guard for this in Celerity.

You should change:

puts browser.table(:xpath, "//*[@id='test']/table/tbody/tr[5]/td/table[2]/tbody/tr/td").exist?

to

puts browser.cell(:xpath, "//*[@id='test']/table/tbody/tr[5]/td/table[2]/tbody/tr/td").exist?

At least in Celerity, cell() can also be replaced with td(). Even if Watir understands the exist? call, I suspect you will run into problems trying to use the returned element later, since the underlying DOM object is not a table.

If you just want to verify that the XPath is valid, you could also use

browser.element_by_xpath("//....").exists?