Sha256: d658cf1fe640362a14d4c5c61b3984d7ca7e918a102edbfec898d3c42d23d94c

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 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
          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 do |row|
            row.cells.any? { |col| col.text.include? row_title }
          end
        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
page-object-0.8.4 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.8.3 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.8.2 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.8.1 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.8 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.6 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.5.1 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.5 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.4 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.3 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.2 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.1 lib/page-object/platforms/watir_webdriver/table.rb
page-object-0.7.0 lib/page-object/platforms/watir_webdriver/table.rb