Sha256: 46eb61be6b6fe0daeb10848b98c964ae0b4ba02f44978353bd779dae686e2fb0
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
module Symbiont module WebObjects class TableRow < WebObject include Enumerable def initialize(web_object) @web_object = web_object end # This method is used to return a TableCell object based on the index provided. When # the index provided is a string, the text will be matched with the text from the # columns in the first row. # @return [Symbiont::WebObjects::TableCell] def [](index) index = find_by_title(index) if index.kind_of?(String) return nil unless index && columns >= index + 1 ::Symbiont::WebObjects::TableCell.new(web_object[index]) end # This method is an iterator that returns a TableCell object each time through # the loop. # @return [Symbiont::WebObjects::TableCell] def each for index in 1..self.columns do yield self[index - 1] end end # This method returns the number of columns in a table object. def columns web_object.wd.find_elements(:xpath, cell_xpath).size end protected def cell_xpath ".//child::td|th" end def initialize_cell(element) ::Symbiont::WebObjects::TableCell.new(element) end private def find_by_title(column_text) table = web_object.parent table = table.parent if table.tag_name == 'tbody' first_row = table[0] first_row.cells.find_index {|column| column.text.include? column_text} end end # class: TableRow ::Symbiont::WebObjects.class_for_tag[:tr] = ::Symbiont::WebObjects::TableRow end # module: WebObjects end # module: Symbiont
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
symbiont-0.2.1 | lib/symbiont/web_objects/table_row.rb |
symbiont-0.2.0 | lib/symbiont/web_objects/table_row.rb |