Sha256: 05e6200d51ddddd5767c569cb63e62709c085f035065a535f347dfcda59c19be

Contents?: true

Size: 520 Bytes

Versions: 12

Compression:

Stored size: 520 Bytes

Contents

# encoding: utf-8
module Watir
  class Table < HTMLElement

    #
    # The table as an 2D Array of strings with the text of each cell.
    #
    # @return [Array<Array<String>>]
    #

    def to_a
      assert_exists

      trs.inject [] do |res, row|
        res << row.wd.find_elements(:xpath, ".//td | .//th").map { |cell| cell.text }
      end
    end

    #
    # Get the n'th row of this table.
    #
    # @return Watir::TableRow
    #

    def [](idx)
      row(:index, idx)
    end

  end # Table
end # Watir

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
watir-webdriver-0.0.9 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.8 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.7 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.6 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.5 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.4 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.3 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.2 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.1 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.1.dev7 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.1.dev6 lib/watir-webdriver/elements/table.rb
watir-webdriver-0.0.1.dev5 lib/watir-webdriver/elements/table.rb