Sha256: 40e6776df63fdab5212fa6f457f314004711e560d48c988b776cce06c22afd0e

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

module PageObject
  module Platforms
    module SeleniumWebDriver
      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)
          eles = table_rows
          idx = find_index_by_title(idx, eles) if idx.kind_of?(String)
          return nil unless idx
          initialize_row(eles[idx], :platform => :selenium_webdriver)
        end

        #
        # Returns the number of rows in the table.
        #
        def rows
          table_rows.size
        end

        private

        def find_index_by_title(row_title, eles)
          eles.find_index do |row|
            columns = row.find_elements(:xpath, ".//child::td|th")
            columns.any? { |col| col.text.include? row_title }
          end
        end

        def table_rows
          element.find_elements(:xpath, child_xpath)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
page-object-1.1.1 lib/page-object/platforms/selenium_webdriver/table.rb
page_object-1.1.3 lib/page-object/platforms/selenium_webdriver/table.rb
page_object-1.1.2 lib/page-object/platforms/selenium_webdriver/table.rb
page_object-1.1.1 lib/page-object/platforms/selenium_webdriver/table.rb
page-object-1.1.0 lib/page-object/platforms/selenium_webdriver/table.rb
page-object-1.0.3 lib/page-object/platforms/selenium_webdriver/table.rb
meeane-page-object-0.1.11 lib/page-object/platforms/selenium_webdriver/table.rb
page-object-1.0.2 lib/page-object/platforms/selenium_webdriver/table.rb
page-object-1.0.1 lib/page-object/platforms/selenium_webdriver/table.rb
page-object-1.0 lib/page-object/platforms/selenium_webdriver/table.rb
page-object-0.9.8 lib/page-object/platforms/selenium_webdriver/table.rb
page-object-0.9.7 lib/page-object/platforms/selenium_webdriver/table.rb