lib/page-object/accessors.rb in page-object-0.0.1 vs lib/page-object/accessors.rb in page-object-0.0.2
- old
+ new
@@ -161,11 +161,99 @@
define_method("#{name}_radio_button") do
platform.radio_button_for identifier
end
end
+ #
+ # adds two methods - one to click a button and another to
+ # return the button element.
+ #
+ # Example: button(:purchase, :id => 'purchase')
+ # will generate a 'purchase' and 'purchase_button' methods.
+ #
+ # @param the name used for the generated methods
+ # @param identifier how we find a checkbox. The valid values are:
+ # :class => Watir and Selenium
+ # :id => Watir and Selenium
+ # :index => Watir only
+ # :name => Watir and Selenium
+ # :text => Watir only
+ # :xpath => Watir and Selenium
+ #
def button(name, identifier)
define_method(name) do
+ platform.click_button_for identifier
+ end
+ define_method("#{name}_button") do
+ platform.button_for identifier
+ end
+ end
+
+ #
+ # adds two methods - one to retrieve the text from a div
+ # and another to return the div element
+ #
+ # Example: div(:message, {:id => 'message'})
+ # will generate a 'message' and 'message_div' methods
+ #
+ # @param the name used for the generated methods
+ # @param identifier how we find a checkbox. The valid values are:
+ # :class => Watir and Selenium
+ # :id => Watir and Selenium
+ # :index => Watir only
+ # :name => Selenium only
+ # :xpath => Watir and Selenium
+ #
+ def div(name, identifier)
+ define_method("#{name}") do
+ platform.div_text_for identifier
+ end
+ define_method("#{name}_div") do
+ platform.div_for identifier
+ end
+ end
+
+ #
+ # adds a method to retrieve the table element
+ #
+ # Example: table(:cart, :id => 'shopping_cart')
+ # will generate a 'cart_table' method.
+ #
+ # @param the name used for the generated methods
+ # @param identifier how we find a checkbox. The valid values are:
+ # :class => Watir and Selenium
+ # :id => Watir and Selenium
+ # :index => Watir only
+ # :name => Selenium only
+ # :xpath => Watir and Selenium
+ #
+ def table(name, identifier)
+ define_method("#{name}_table") do
+ platform.table_for identifier
+ end
+ end
+
+ #
+ # adds two methods one to retrieve the text from a table cell
+ # and another to return the table cell element
+ #
+ # Example: cell(:total, :id => 'total_cell')
+ # will generate a 'total' and 'total_cell' methods
+ #
+ # @param the name used for the generated methods
+ # @param identifier how we find a checkbox. The valid values are:
+ # :class => Watir and Selenium
+ # :id => Watir and Selenium
+ # :index => Watir only
+ # :name => Selenium only
+ # :xpath => Watir and Selenium
+ #
+ def cell(name, identifier)
+ define_method("#{name}") do
+ platform.cell_text_for identifier
+ end
+ define_method("#{name}_cell") do
+ platform.cell_for identifier
end
end
end
end