Sha256: fa65ec4f4646a1ca00413d3e21bfc326251999c18232586642265cf0c51105cd

Contents?: true

Size: 1.18 KB

Versions: 26

Compression:

Stored size: 1.18 KB

Contents

module PageObject
  module Platforms
    module SeleniumWebDriver

      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.
        # The text can be a substring of the full column text.
        #
        def [](idx)
          els = table_cells
          idx = find_index_by_title(idx) if idx.kind_of?(String)
          return nil unless idx  && columns >= idx + 1
          initialize_cell(els[idx], :platform => :selenium_webdriver)
        end

        #
        # Returns the number of columns in the table.
        #
        def columns
          table_cells.size
        end

        private

        def find_index_by_title(title)
          table = parent
          parent_tag_name = parent.element.tag_name
          table = table.parent if (parent_tag_name == 'tbody' || parent_tag_name == 'thead')
          table[0].find_index { |column| column.text.include? title }
        end

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

      end
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
page-object-1.1.1 lib/page-object/platforms/selenium_webdriver/table_row.rb
page_object-1.1.3 lib/page-object/platforms/selenium_webdriver/table_row.rb
page_object-1.1.2 lib/page-object/platforms/selenium_webdriver/table_row.rb
page_object-1.1.1 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-1.1.0 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-1.0.3 lib/page-object/platforms/selenium_webdriver/table_row.rb
meeane-page-object-0.1.11 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-1.0.2 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-1.0.1 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-1.0 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.8 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.7 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.6 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.5 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.4 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.3 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.2 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.1 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.9.0 lib/page-object/platforms/selenium_webdriver/table_row.rb
page-object-0.8.10 lib/page-object/platforms/selenium_webdriver/table_row.rb