Class: Watir::Table
- Inherits:
-
HTMLElement
- Object
- BaseElement
- HTMLElement
- Watir::Table
- Defined in:
- lib/watir-webdriver/elements/table.rb,
lib/watir-webdriver/elements/generated.rb,
lib/watir-webdriver/elements/generated.rb
Constant Summary
Constants inherited from BaseElement
BaseElement::IGNORED_ATTRIBUTES
Instance Method Summary collapse
-
#[](idx) ⇒ Object
Get the n’th row of this table.
-
#to_a ⇒ Array<Array<String>>
The table as an 2D Array of strings with the text of each cell.
Methods inherited from BaseElement
attribute_list, #attribute_value, attributes, #click, #double_click, #driver, #element, #exists?, #fire_event, #flash, #focus, #html, #initialize, #inspect, #parent, #right_click, #run_checkers, #send_keys, #style, #tag_name, #text, typed_attributes, #value, #visible?
Methods included from Container
Methods included from XpathSupport
#element_by_xpath, #elements_by_xpath
Constructor Details
This class inherits a constructor from Watir::BaseElement
Instance Method Details
#[](idx) ⇒ Object
Get the n’th row of this table.
25 26 27 |
# File 'lib/watir-webdriver/elements/table.rb', line 25 def [](idx) row(:index, idx) end |
#to_a ⇒ Array<Array<String>>
The table as an 2D Array of strings with the text of each cell.
11 12 13 14 15 16 17 |
# File 'lib/watir-webdriver/elements/table.rb', line 11 def to_a assert_exists trs.inject [] do |res, row| res << row.wd.find_elements(:xpath, ".//td | .//th").map { |cell| cell.text } end end |