Skip to content

Instantly share code, notes, and snippets.

@jarib
Created September 4, 2010 22:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarib/565553 to your computer and use it in GitHub Desktop.
Save jarib/565553 to your computer and use it in GitHub Desktop.
Revised Watir Table API
module Container
# finds ALL descendant <th> elements of the container
def th() end # returns TableHeaderCell
def ths() end # returns TableHeaderCellCollection
# finds ALL descendant <tfoot> elements of the container
def tfoot() end # returns TableSection
def tfoots() end # returns TableSectionCollection
# finds ALL descendant <thead> elements of the container
def thead() end # returns TableSection
def theads() end # returns TableSectionCollection
# finds ALL descendant <tbody> elements of the container
def tbody() end # returns TableSection
def tbodys() end # returns TableSectionCollection
# finds ALL descendant <td> elements of the container
def td() end # returns TableDataCell
def tds() end # returns TableDataCellCollection
# finds ALL descendant <tr> elements of the container
def tr() end # returns TableRow
def trs() end # returns TableRowCollection
# finds ALL descendant <caption> elements of the container
def caption() end # returns TableCaption
def captions() end # returns TableCaptionCollection
end
class HTMLElement
include Container
end
class Table < HTMLElement
# finds <tr> elements belonging to this Table (excluding nested tables)
def row() end # returns TableRow
def rows() end # returns TableRowCollection
# equivalent to row(:index => n)
def [](n) end # returns TableRow
# the text of each cell in this table (excluding nested tables)
# (previously to_a)
def strings() end # returns Array of String
# if the first row only contains <th> elements, for each subsequent row,
# creates a Hash mapping text of header cell => text of data cell
#
# otherwise, raises an exception
def hashes() end # Array of Hash
end
class TableRow < HTMLElement
# finds <th> and <tr> elements in this row
def cell() end # returns TableCell
def cells() end # returns TableCellCollection
# equivalent to cell(:index => n)
def [](n) end # returns TableCell
# the text of each cell in this row (excluding nested tables)
# (previously to_a)
def strings() end # returns Array of String
end
class TableCell < HTMLElement; end
class TableDataCell < TableCell; end
class TableHeaderCell < TableCell; end
class TableSection < HTMLElement
# finds <tr> elements that are children of this element
def row() end # return TableRow
def rows() end # return TableRowCollection
# equivalent to row(:index => n)
def [](n) end # returns TableRow
# the text of each cell in this section (excluding nested tables)
# (previously to_a)
def strings() end # returns Array of String
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment