[wtr-general] Re: Modeling web pages and table rows

2009-08-11 Thread Jim Evans

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)
  end

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

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

I tried have VisibleTickets return TableRows.new(self), 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
territory.

On Aug 10, 7:49 pm, Bret Pettichord bpettich...@gmail.com wrote:
 Can you show us what you tried?

 On Aug 10, 9:07 am, Jim Evans jim.ev...@numarasoftware.com 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 watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: Modeling web pages and table rows

2009-08-10 Thread Bret Pettichord

Can you show us what you tried?

On Aug 10, 9:07 am, Jim Evans jim.ev...@numarasoftware.com 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.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---