module Symbiont module WebObjects class Table < WebObject include Enumerable def initialize(web_object, platform) @web_object = web_object include_platform_specifics_for(platform) end # This method is an iterator that returns a TableRow object each time through # the loop. # @return [Symbiont::WebObjects::TableRow] def each for index in 1..self.rows do yield self[index - 1] end end # Returns a reference to the first row web object of a table. # @return [Symbiont::WebObjects::TableRow] def first_row self[0] end # Returns a reference to the last row web object of a table. # @return [Symbiont::WebObjects::TableRow] def last_row self[-1] end protected def row_xpath ".//child::tr" end def include_platform_specifics_for(platform) super if platform[:platform] == :watir_webdriver require 'symbiont/platform_watir/web_objects/table' self.class.send :include, Symbiont::Platforms::WatirWebDriver::Table elsif platform[:platform] == :selenium_webdriver require 'symbiont/platform_selenium/web_objects/table' self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::Table else raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported." end end end # class: Table ::Symbiont::WebObjects.class_for_tag[:table] = ::Symbiont::WebObjects::Table end # module: WebObjects end # module: Symbiont