lib/page-object/platforms/selenium_table.rb in page-object-0.0.4 vs lib/page-object/platforms/selenium_table.rb in page-object-0.0.5

- old
+ new

@@ -4,21 +4,35 @@ # # Return the PageObject::Elements::TableRow for the index provided. Index # is zero based. # + # @return [PageObject::Elements::TableRow] + # def [](idx) - element = @element.find_element(:xpath, ".//tr[#{idx+1}]") - PageObject::Elements::TableRow.new(element, :platform => :selenium) + eles = table_rows + PageObject::Elements::TableRow.new(eles[idx], :platform => :selenium) end # + # Returns the number of rows in the table. + # + def rows + table_rows.size + end + + # # override PageObject::Platforms::SeleniumElement because exists? is not # available on a table element in Selenium. # def exists? raise "exists? not available on table element" end + private + + def table_rows + @element.find_elements(:xpath, child_xpath) + end end end end \ No newline at end of file