So in addition to the SafariWatir aspect of the issue.  I just checked
that page, and there are 4 tables all with the same ID value..  That's
going to need to be fixed for you to use ID to reliably identify the
proper table.    Until that's changed, you'll need to use some other
way to identify the table you want.

With the current layout of the page, that's tricky.  The Table_01
tables appear to be nested, and contain the value you are looking for
both inside a bodytext paragraph, and also a table of stats for the
Santee 100, and that table has NO attributes at all

I'd talk to your developers about getting some unique ID values, or
names on some of those tables..  For example on the table below the
span for 'Santee 100' if they could perhaps put an ID value there of
something like "Specs_Santee100"  then it would make the site much
more testable and make it far easier for you to do your work.   Or
even if they did something like had a div with ID "Santee100" which
contained the span with the title, and a table with name something
like "Specifications", then under Watir you could look within the
named span, for the named table, and inside that table a specific row
(such as second row), and a specific index of a cell along that row,
and see if it held the right value.

In that case the code to get the text for that cell could look
something like

browser.div(:name, 'Santee 100'),table(:name, 'Specifications')[2]
[2].text

Those kind of changes would not only make the site more testable, but
would make the test code a lot more readable.



On Sep 16, 10:13 am, Chuck van der Linden <[email protected]> wrote:
> I'll wager the ID value 'Table_01'  is not unique within the document,
> and some other element that is NOT a table is being returned when
> Watir goes out and tries to get 'the element with ID 'Table_01'.
>
> I've seen that kind of thing before where people have invalid HTML and
> ID values are not unique.
>
> display the source and search for "Table_01' and see if you find it
> being used more than once as an ID attribute value.  If my guess is
> right, you'll see it used more than once for ID.  (it's ok to have
> names, and many other HTML attributes repeated, but ID's are supposed
> to be unique within a page)   If I'm wrong we'll have to look for some
> other source for the problem.
>
> If ID values are being repeated within a page, write up a bug that the
> developers are producing invalid HTML, and ID values in the HTML are
> not unique within a page as per the HTML standard.   Then if you need
> to get the script to run prior to them fixing that, find some other
> means to identify the table.
>
> On Sep 15, 10:31 am, Rajiv Nanduani <[email protected]>
> wrote:
>
>
>
> > hi
> > try this as Z suggested
>
> > require 'rubygems'
> > require 'safariwatir'
> > browser = Watir::Safari.new
> > browser.goto("http://www.hurricaneaquasports.com/santee-100.html";)
> > if browser.table(:id, "Table_01").text.include?("33 lbs")
> >  puts "Data Verify passed"
> > else
> >   puts "Data Verify FAILED. Ouch."
> > end
>
> > or
>
> > require 'rubygems'
> > require 'safariwatir'
> > browser = Watir::Safari.new
> > browser.goto("http://www.hurricaneaquasports.com/santee-100.html";)
> > if browser.table(:id, "Table_01").html.include?("33 lbs")
> >  puts "Data Verify passed"
> > else
> >   puts "Data Verify FAILED. Ouch."
> >  end
>
> > On Wed, Sep 15, 2010 at 10:52 PM, Watir General <[email protected]> wrote:
> > > I appreciate everyone's input! :) however I still get
> > > NoMethodErrors...
>
> > > I have a similar version of the script I'm trying to create here for
> > > just some random website with table data:
>
> > > require 'rubygems'
> > > require 'safariwatir'
> > > browser = Watir::Safari.new
> > > browser.goto("http://www.hurricaneaquasports.com/santee-100.html";)
> > > if browser.table(:id, "Table_01").cell(:text, "33 lbs").exists?
> > >  puts "Data Verify passed"
> > > else
> > >   puts "Data Verify FAILED. Ouch."
> > > end
>
> > > When I run that I get this.....
> > > _____________________________________
> > > NoMethodError: undefined method ‘cell’ for #<Watir::Container::Table:
> > > 0x1010ede48>
>
> > > at top level    in Test for Cell Data.rb at line 6
> > > _____________________________________
>
> > > any thoughts?
>
> > > On Sep 15, 11:41 am, Chuck van der Linden <[email protected]> wrote:
> > > > If Z's approach below doesn't work (first thing I would have
> > > > suggested) you could also try something along these lines (especially
> > > > the first one if you know that a single cell should contain just that
> > > > text and nothing more)
>
> > > >  if browser.table(:id, "dataTableBody").cell(:text, "146173").exists?
> > > > or
> > > >   if browser.table(:id, "dataTableBody").row(:text, /146173/).exists?
>
> > > > On Sep 15, 1:02 am, Željko Filipin <[email protected]>
> > > > wrote:
>
> > > > > On Tue, Sep 14, 2010 at 9:58 PM, Watir General <[email protected]>
> > > wrote:
> > > > > > 9    if browser.table(:id, "dataTableBody").include?("146173")
> > > > > > NoMethodError: undefined method `include?' for
> > > > > > #<Watir::Container::Table:0x1010e1710>
>
> > > > > You are calling "include?" method on a table object, and Ruby
> > > complains. You
> > > > > should call the method on table text (or html).
>
> > > > > Example (not tested):
>
> > > > > browser.table(:id, "dataTableBody").text.include?("146173")
>
> > > > > Željko
> > > > > --
> > > > > watir.com - community manager
> > > > > watirpodcast.com - host
> > > > > testingpodcast.com - audio podcasts on software testing. all of them
>
> > > --
> > > Before posting, please readhttp://watir.com/support. In short: search
> > > before you ask, be nice.
>
> > > You received this message because you are subscribed to
> > >http://groups.google.com/group/watir-general
> > > To post: [email protected]
> > > To unsubscribe: 
> > > [email protected]<watir-general%2bunsubscr...@goog
> > >  legroups.com>
>
> > --
> > RAJIV KUMAR
>
> > <http://rajivkumarnandvani.wordpress.com/>
> > <http://learnqtphelp.blogspot.com/>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: [email protected]
To unsubscribe: [email protected]

Reply via email to