Sha256: bd1e64f4d442956154630d0974667669b1b94080992f2e724781424ca11d3536

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

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 any column. The text can be a substring of the full column text.
        #
        # @return [PageObject::Elements::TableRow]
        #
        def [](idx)
          idx = find_index_by_title(idx) if idx.kind_of?(String)
          return nil unless idx
          initialize_row(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 do |row|
            row.cells.any? { |col| col.text.include? row_title }
          end
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
page-object-lds-0.0.14 lib/page-object/platforms/watir_webdriver/table.rb
page-object-lds-0.0.13 lib/page-object/platforms/watir_webdriver/table.rb
page-object-lds-0.0.12 lib/page-object/platforms/watir_webdriver/table.rb
page-object-lds-0.0.11 lib/page-object/platforms/watir_webdriver/table.rb
page-object-lds-0.0.1 lib/page-object/platforms/watir_webdriver/table.rb
meeane-page-object-0.1.10 lib/page-object/platforms/watir_webdriver/table.rb
meeane-page-object-0.1.8 lib/page-object/platforms/watir_webdriver/table.rb