Class: Druid::Elements::Table

Inherits:
Element
  • Object
show all
Defined in:
lib/druid/elements/table.rb

Instance Attribute Summary

Attributes inherited from Element

#driver, #element

Instance Method Summary collapse

Methods inherited from Element

#==, #check_exist, #check_visible, #children, #disabled?, #following_sibling, #following_siblings, #initialize, #method_missing, #name, #parent, #preceding_sibling, #preceding_siblings, #present?, #respond_to_missing?, #siblings, #wait_until, #when_not_present, #when_present

Methods included from Assist

#area_for, #areas_for, #audio_for, #audios_for, #b_for, #b_text_for, #bs_for, #button_for, #buttons_for, #canvas_for, #canvass_for, #cell_for, #cell_text_for, #cells_for, #check_checkbox, #checkbox_checked?, #checkbox_for, #checkboxs_for, #click_area_for, #click_button_for, #click_link_for, #div_for, #div_text_for, #divs_for, #element_for, #elements_for, #file_field_for, #file_field_value_set, #file_fields_for, #form_for, #forms_for, #h1_for, #h1_text_for, #h1s_for, #h2_for, #h2_text_for, #h2s_for, #h3_for, #h3_text_for, #h3s_for, #h4_for, #h4_text_for, #h4s_for, #h5_for, #h5_text_for, #h5s_for, #h6_for, #h6_text_for, #h6s_for, #hidden_field_for, #hidden_field_value_for, #hidden_fields_for, #i_for, #i_text_for, #image_for, #image_loaded_for, #images_for, #is_for, #label_for, #label_text_for, #labels_for, #link_for, #links_for, #list_item_for, #list_item_text_for, #list_items_for, #ordered_list_for, #ordered_list_text_for, #ordered_lists_for, #page_for, #pages_for, #paragraph_for, #paragraph_text_for, #paragraphs_for, #radio_button_for, #radio_buttons_for, #radio_selected?, #row_for, #row_text_for, #rows_for, #select_list_for, #select_list_value_for, #select_list_value_set, #select_lists_for, #select_radio, #span_for, #span_text_for, #spans_for, #svg_for, #svgs_for, #table_for, #table_text_for, #tables_for, #text_area_for, #text_area_value_for, #text_area_value_set, #text_areas_for, #text_field_for, #text_field_value_for, #text_field_value_set, #text_fields_for, #uncheck_checkbox, #unordered_list_for, #unordered_list_text_for, #unordered_lists_for, #video_for, #videos_for

Methods included from NestedElements

included

Constructor Details

This class inherits a constructor from Druid::Elements::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Druid::Elements::Element

Instance Method Details

#[](what) ⇒ Druid::Elements::TableRow

Return the Druid::Elements::Table 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.



12
13
14
15
# File 'lib/druid/elements/table.rb', line 12

def [](what)
  idx = find_index(what)
  idx && row_items[idx]
end

#column_values(what) ⇒ Object

Returns the Array of values(String) in a column 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 header. The text can be a substring of the full header text



56
57
58
59
# File 'lib/druid/elements/table.rb', line 56

def column_values(what)
  idx = find_index_of_header(what)
  idx && row_items.drop(1).collect{ |row| row.cell(index: idx).text }
end

#each(&block) ⇒ Druid::Elements::TableRow

iterator that yields with a Druid::Elements::TableRow



29
30
31
# File 'lib/druid/elements/table.rb', line 29

def each(&block)
  row_items.each(&block)
end

#first_rowObject

return the first row

Returns:

  • Druid::Elements::TableRow



38
39
40
# File 'lib/druid/elements/table.rb', line 38

def first_row
  self[0]
end

#last_rowObject

return the last row

Returns:

  • Druid::Elements::TableRow



47
48
49
# File 'lib/druid/elements/table.rb', line 47

def last_row
  self[-1]
end

#rowsObject

Returns the number of rows in the table.



20
21
22
# File 'lib/druid/elements/table.rb', line 20

def rows
  row_items.size
end