lib/gametel/accessors.rb in gametel-0.2 vs lib/gametel/accessors.rb in gametel-0.3
- old
+ new
@@ -4,20 +4,23 @@
# Generates two method to enter text into a text field and to
# clear the text field
#
# @example
# text(:first_name, :index => 0)
- # # will generate 'first_name=' and 'clear_first_name' methods
+ # # will generate 'first_name', 'first_name=' and 'clear_first_name' methods
#
# @param [String] the name used for the generated methods
# @param [Hash] locator for how the text is found The valid
# keys are:
# * :content_description
# * :id
# * :index
#
def text(name, locator)
+ define_method("#{name}") do
+ platform.get_text(locator)
+ end
define_method("#{name}=") do |value|
platform.enter_text(value, locator)
end
define_method("clear_#{name}") do
platform.clear_text(locator)
@@ -126,9 +129,26 @@
# * :id
#
def view(name, locator)
define_method(name) do
platform.click_view(locator)
+ end
+ end
+
+ #
+ # Generates one method to get the selected item text.
+ # @example
+ # spinner(:spinner_item, :id => 'id_name_of_your_control')
+ # # will generate 'spinner_item' method
+ #
+ # @param [String] the name used for the generated methods
+ # @param [Hash] locator indicating an id for how the spinner is found.
+ # The only valid keys are:
+ # * :id
+ #
+ def spinner(name, locator)
+ define_method(name) do
+ platform.get_spinner_value(locator) if locator[:id]
end
end
end
end