Jarmo answers the located false question below. Bottom line is that's not really the way to tell if something exists or not.
https://groups.google.com/d/topic/watir-general/5IAZsmFh9Ow/discussion On Thursday, August 9, 2012 9:06:43 AM UTC-4, Dan wrote: > > Indexes start at 0, so that's part of the problem. > > >> b.table(:index, 0).text.include?('housing') > => true > >> b.table(:index, 1).text.include?('housing') > => false > > Also, you're better off using something like the exists method. I think > someone else can explain why located=false much better than I can, but I'm > sure that's been answered before on this forum. > > >> b.table(:index, 0) > => #<Watir::Table:0x1010e1c60 located=false selector={:tag_name=>"table", > :index=>0}> > >> b.table(:index, 0).exists? > => true > > On Wednesday, August 8, 2012 9:12:36 PM UTC-4, johnssn wrote: >> >> I created a HTML doc with a table containing a tbody. Sort of ran into >> the same thing: >> >> irb(main):005:0> b = Watir::Browser.new >> => #<Watir::IE:0x40391b8 url="about:blank" title=""> >> >> irb(main):006:0> b.table(:index, 1).html >> Watir::Exception::UnknownObjectException: Unable to locate element, using >> {:index=>1, :tag_name=>["table"]} >> >> irb(main):007:0> b.html >> => "<HTML><HEAD></HEAD>\r\n<BODY>\r\n<TABLE >> border=1>\r\n<THEAD>\r\n<TR>\r\n<TH>Month</TH>\r\n<TH>Sa >> >> vings</TH></TR></THEAD>\r\n<TFOOT>\r\n<TR>\r\n<TD>Sum</TD>\r\n<TD>$180</TD></TR></TFOOT>\r\n<TBODY>\ >> >> r\n<TR>\r\n<TD>January</TD>\r\n<TD>$100</TD></TR>\r\n<TR>\r\n<TD>February</TD>\r\n<TD>$80</TD></TR>< >> /TBODY></TABLE></BODY></HTML>" >> >> irb(main):008:0> b.tables.length >> => 1 >> >> Then I tried going to craigslist. Watir sees 3 tables when I call the >> tables method (after I drill down to a community page). But then when I try >> to access them using :index it can't seem to find it. >> >> irb(main):019:0> b.goto('www.craigslist.com.com') >> => 1.312122 >> irb(main):020:0> b.goto('www.craigslist.com') >> => 0.577959 >> irb(main):021:0> b.tables.length >> => 0 >> irb(main):022:0> b.tables.length >> => 3 >> irb(main):023:0> b.table(:index, 1) >> => #<Watir::Table:0x3da1318 located=false specifiers={:index=>1, >> :tag_name=>["table"]}> >> irb(main):024:0> b.table(:index, 1) >> >> But :id works: >> >> irb(main):033:0> b.table(:id, 'container').text.include?('housing') >> => true >> >> Maybe I'm doing something stupid (or something's changed) but it seems >> like :index isn't working. I just downloaded the watir classic gem this >> evening. >> >> ------------------------------ >> *From:* Wind Dive <arbnju...@gmail.com> >> *To:* watir-...@googlegroups.com >> *Sent:* Wednesday, August 8, 2012 11:56 AM >> *Subject:* Re: [wtr-general] Rich Face Testing with Watir >> >> Got this error, >> Watir::Exception::UnknownObjectException: Unable to locate element, using >> {:tag_name=>["body"], :index=>1} >> >> On Wed, Aug 8, 2012 at 2:48 PM, John Fitisoff <jfit...@yahoo.com> wrote: >> >> Sorry, think I should have said 'body' rather than tbody: >> >> b.table(:class, 'rich-tree-node').body(: index, 1) .html >> >> >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> watir-...@googlegroups.com >> http://groups.google.com/group/watir-general >> watir-genera...@googlegroups.com >> >> >> -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com