Sha256: 1552cdf7f5eb8c43ba946e97384168ab2bfb991612705bd3f009fbf037a7d18d

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

module PageObject
  module Platforms
    module WatirWebDriver

      module Table

        #
        # Return the PageObject::Elements::TableRow 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 first column.
        #
        # @return [PageObject::Elements::TableRow]
        #
        def [](idx)
          idx = find_index_by_title(idx) if idx.kind_of?(String)
          return nil unless idx
          Object::PageObject::Elements::TableRow.new(element[idx], :platform => :watir_webdriver)
        end

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

        private

        def find_index_by_title(row_title)
          element.rows.find_index {|row| row[0].text == row_title}
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page-object-0.6.9 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.6.8 lib/page-object/platforms/watir_webdriver/table.rb