Class: Symbiont::WebObjects::Table
- Includes:
- Enumerable
- Defined in:
- lib/symbiont/web_objects/table.rb
Instance Attribute Summary
Attributes inherited from WebObject
Instance Method Summary collapse
-
#[](index) ⇒ Symbiont::WebObjects::TableRow
This method is used to return a TableRow object based on the index provided.
-
#each ⇒ Symbiont::WebObjects::TableRow
This method is an iterator that returns a TableRow object each time through the loop.
-
#first_row ⇒ Symbiont::WebObjects::TableRow
Returns a reference to the first row web object of a table.
-
#initialize(web_object) ⇒ Table
constructor
A new instance of Table.
-
#last_row ⇒ Symbiont::WebObjects::TableRow
Returns a reference to the last row web object of a table.
-
#rows ⇒ Object
This method will return the number of rows in a table.
Methods inherited from WebObject
#==, #attribute, #clear, #click, #disabled?, #double_click, #enabled?, #exists?, #fire_event, #flash, #focus, #hover, #html, #id, #inspect, #parent, provide_locator_for, #scroll_into_view, selector_mapping, #send_keys, #style, #tag_name, #text, usable_selectors, #value, #visible?, #wait_until, #when_actionable, #when_not_actionable, #when_not_visible, #when_visible
Constructor Details
#initialize(web_object) ⇒ Table
Returns a new instance of Table.
7 8 9 |
# File 'lib/symbiont/web_objects/table.rb', line 7 def initialize(web_object) @web_object = web_object end |
Instance Method Details
#[](index) ⇒ Symbiont::WebObjects::TableRow
This method is used to return a TableRow object based on the index provided. When the index provided is a string, the text will be matched with the text from the first column.
15 16 17 18 19 |
# File 'lib/symbiont/web_objects/table.rb', line 15 def [](index) index = find_by_title(index) if index.kind_of?(String) return nil unless index ::Symbiont::WebObjects::TableRow.new(web_object[index]) end |
#each ⇒ Symbiont::WebObjects::TableRow
This method is an iterator that returns a TableRow object each time through the loop.
24 25 26 27 28 |
# File 'lib/symbiont/web_objects/table.rb', line 24 def each for index in 1..self.rows do yield self[index - 1] end end |
#first_row ⇒ Symbiont::WebObjects::TableRow
Returns a reference to the first row web object of a table.
37 38 39 |
# File 'lib/symbiont/web_objects/table.rb', line 37 def first_row self[0] end |
#last_row ⇒ Symbiont::WebObjects::TableRow
Returns a reference to the last row web object of a table.
43 44 45 |
# File 'lib/symbiont/web_objects/table.rb', line 43 def last_row self[-1] end |
#rows ⇒ Object
This method will return the number of rows in a table.
31 32 33 |
# File 'lib/symbiont/web_objects/table.rb', line 31 def rows web_object.wd.find_elements(:xpath, row_xpath).size end |