Sha256: 93b38955fe1c68dd18c4d249798286eea61a772419e0761f5090d3c643824263

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

module PageObject
  module Platforms
    module WatirWebDriver
      module TableRow

        #
        # Return the PageObject::Elements::TableCell for the index provided.  Index
        # is zero based.  If the index provided is a String then it
        # will be matched with the text from the columns in the first row.
        #
        def [](idx)
          idx = find_index_by_title(idx) if idx.kind_of?(String)
          Object::PageObject::Elements::TableCell.new(element[idx], :platform => :watir_webdriver)
        end

        #
        # Returns the number of columns in the table.
        #
        def columns
          element.wd.find_elements(:xpath, child_xpath).size
        end

        private

        def find_index_by_title(title)
          table = element.parent
          first_row = table[0]
          first_row.cells.find_index {|column| column.text == title}
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
page-object-0.6.7 lib/page-object/platforms/watir_webdriver/table_row.rb