lib/page-object/accessors.rb in page-object-0.5.3 vs lib/page-object/accessors.rb in page-object-0.5.4
- old
+ new
@@ -61,21 +61,22 @@
# * :id => Watir and Selenium
# * :index => Watir and Selenium
# * :name => Watir and Selenium
# * :tag_name => Watir and Selenium
# * :text => Watir only
+ # * :title => Watir and Selenium
# * :value => Watir only
# * :xpath => Watir and Selenium
# @param optional block to be invoked when element method is called
#
def text_field(name, identifier=nil, &block)
define_method(name) do
return platform.text_field_value_for identifier.clone unless block_given?
self.send("#{name}_element").value
end
define_method("#{name}=") do |value|
- return platform.text_field_value_set(identifier.clone, value) unless block_given?
+ return platform.text_field_value_set(identifier.clone, value) unless block_given?
self.send("#{name}_element").value = value
end
define_method("#{name}_element") do
return call_block(&block) if block_given?
platform.text_field_for(identifier.clone)
@@ -464,14 +465,16 @@
# # will generate a 'logo_element' method
#
# @param [String] the name used for the generated methods
# @param [Hash] identifier how we find an image. You can use a multiple paramaters
# by combining of any of the following except xpath. The valid keys are:
+ # * :alt => Watir and Selenium
# * :class => Watir and Selenium
# * :id => Watir and Selenium
# * :index => Watir and Selenium
# * :name => Watir and Selenium
+ # * :src => Watir and Selenium
# * :xpath => Watir and Selenium
# @param optional block to be invoked when element method is called
#
def image(name, identifier=nil, &block)
define_method("#{name}_element") do
@@ -489,10 +492,11 @@
# # will generate a 'login_element' method
#
# @param [String] the name used for the generated methods
# @param [Hash] identifier how we find a form. You can use a multiple paramaters
# by combining of any of the following except xpath. The valid keys are:
+ # * :action => Watir and Selenium
# * :class => Watir and Selenium
# * :id => Watir and Selenium
# * :index => Watir and Selenium
# * :xpath => Watir and Selenium
# @param optional block to be invoked when element method is called
@@ -784,8 +788,38 @@
define_method("#{name}_element") do
return call_block(&block) if block_given?
platform.paragraph_for(identifier.clone)
end
alias_method "#{name}_paragraph".to_sym, "#{name}_element".to_sym
+ end
+
+ #
+ # adds a method to set the file for a file field and to retrieve
+ # the file field element
+ #
+ # @example
+ # file_field(:the_file, :id => 'file_to_upload')
+ # # will generate a 'the_file=' and 'the_file_element' method
+ #
+ # @param [String] the name used for the generated methods
+ # @param [Hash] identifier how we find a file_field. You can use a multiple paramaters
+ # by combining of any of the following except xpath. The valid keys are:
+ # * :class => Watir and Selenium
+ # * :id => Watir and Selenium
+ # * :index => Watir and Selenium
+ # * :name => Watir and Selenium
+ # * :title => Watir and Selenium
+ # * :xpath => Watir and Selenium
+ # @param optional block to be invoked when element method is called
+ #
+ def file_field(name, identifier=nil, &block)
+ define_method("#{name}=") do |value|
+ return platform.file_field_value_set(identifier.clone, value) unless block_given?
+ self.send("#{name}_element").value = value
+ end
+ define_method("#{name}_element") do
+ return call_block(&block) if block_given?
+ platform.file_field_for(identifier.clone)
+ end
end
end
end