lib/page-object/accessors.rb in page-object-0.0.2 vs lib/page-object/accessors.rb in page-object-0.0.3
- old
+ new
@@ -194,27 +194,51 @@
#
# 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:
+ # @param identifier how we find a div. 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
+ define_method(name) do
platform.div_text_for identifier
end
define_method("#{name}_div") do
platform.div_for identifier
end
end
#
+ # adds two methods - one to retrieve the text from a span
+ # and another to return the span element
+ #
+ # Example: span(:alert, {:id => 'alert'})
+ # will generate a 'alert' and 'alert_div' methods
+ #
+ # @param the name used for the generated methods
+ # @param identifier how we find a span. The valid values are:
+ # :class => Watir and Selenium
+ # :id => Watir and Selenium
+ # :index => Watir only
+ # :name => Selenium only
+ # :xpath => Watir and Selenium
+ #
+ def span(name, identifier)
+ define_method(name) do
+ platform.span_text_for identifier
+ end
+ define_method("#{name}_span") do
+ platform.span_for identifier
+ end
+ end
+
+ #
# adds a method to retrieve the table element
#
# Example: table(:cart, :id => 'shopping_cart')
# will generate a 'cart_table' method.
#
@@ -251,9 +275,15 @@
define_method("#{name}") do
platform.cell_text_for identifier
end
define_method("#{name}_cell") do
platform.cell_for identifier
+ end
+ end
+
+ def image(name, identifier)
+ define_method("#{name}_image") do
+ platform.image_for identifier
end
end
end
end