Sure, I'd be happy to. I think, though, that a little more background
might be in order. As I mentioned before, I have a table on the page
which represents a list of tickets. The first row of the table is a
row of header cells; subsequent rows represent individual tickets.
It's a little more complicated, in that the column order is user-
configurable. In other words, the first column is not always the same
data, so I can't rely on position for modeling the content of the row
elements. Initially I tried subclassing the Table object, adding a
couple of attributes that I need, like a Hash containing the current
column bindings. Here's something similar to my class for that table.

class TicketListGridControl < Watir::Table
  def SelectAllTicketsCheckBox
    self.rows[1].checkbox(:name, "MASTER_CHECKBOX")

  def FieldNameMap
    if not instance_variable_defined? :@field_map
      @field_map =
      self.rows[1].cells.each_with_index {|value, index| @field_map
[value]=index }

  def VisibleTickets
    # this method should return the list of tickets.

I tried have VisibleTickets return, since that
doesn't filter out the header row, and I can't see any way to get that
to work. Additionally, using the built in TableRows collections will
not allow me to return objects that extend TableRow. This lead me down
the path of subclassing the TableRows collection, and suddenly it
seems like I'm doing a whole lot of subclassing, rather than just
extending what I need to.

Further, I tried to subclass a TableRow to give me the individual
ticket model, but I can't see how TableRow has any intrinsic knowledge
of the table it belongs to. I suppose I could pass in a reference to
the table's field map hash, but that seems a little clunky. If I
call .parent up the hierarchy on the subclassed TableRow, I can get
the table to which the row belongs, but it's a Watir::Table, not a
TicketListGridControl. I'm know I don't want to extend all tables to
contain these methods.

I'm sure there are other people who are trying to do the type of
semantic page modeling I'm attempting, where the pages to be modeled
are fairly sophisticated. I've had some success generating a model of
the application using WatiN; the latest builds provide a great deal of
plumbing to make this kind of thing dead simple. However, there are
some concerns in my organization about a need for cross-platform (not
just cross-browser) test execution. Thus, I find myself in unfamiliar

On Aug 10, 7:49 pm, Bret Pettichord <> wrote:
> Can you show us what you tried?
> On Aug 10, 9:07 am, Jim Evans <> wrote:
> > I have a web application that I'm trying to create a model of in
> > Watir, to encourage code reuse in the scripts, and I've hit a little
> > snag. I have a table on the main page of the application, the first
> > row of which has column header information. I need a method by which I
> > can return all other rows in the table, ideally without iterating
> > through the rows and adding them to an array. There must be a more
> > efficient way. Certain ports of the Watir library have features that
> > make this very easy, and maybe it's my lack of familiarity with Ruby
> > that is causing my disconnect.- Hide quoted text -
> - Show quoted text -
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to
Before posting, please read the following guidelines:
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to