lib/page-object/accessors.rb in page-object-0.8.10 vs lib/page-object/accessors.rb in page-object-0.9.0
- old
+ new
@@ -1,6 +1,7 @@
require 'erb'
+require 'page-object/locator_generator'
module PageObject
#
# Contains the class level methods that are inserted into your page objects
# when you include the PageObject module. These methods will generate another
@@ -1074,41 +1075,11 @@
# * :index => Watir and Selenium
# * :name => Watir and Selenium
# * :xpath => Watir and Selenium
# @param optional block to be invoked when element method is called
#
- [:abbr,
- :address,
- :article,
- :aside,
- :bdi,
- :bdo,
- :cite,
- :code,
- :dd,
- :dfn,
- :dt,
- :em,
- :figcaption,
- :figure,
- :footer,
- :header,
- :hgroup,
- :kbd,
- :mark,
- :nav,
- :noscript,
- :rp,
- :rt,
- :ruby,
- :samp,
- :section,
- :sub,
- :summary,
- :sup,
- :var,
- :wbr].each do |type|
+ LocatorGenerator::BASIC_ELEMENTS.each do |type|
define_method(type) do |name, *identifier, &block|
identifier = identifier[0] ? identifier[0] : {:index => 0}
element(name, type, identifier, &block)
end
end
@@ -1167,39 +1138,17 @@
# @param [Hash] identifier how we find a text field. You can use a multiple paramaters
# by combining of any of the following except xpath. The valid
# keys are the same ones supported by the standard methods.
# @param optional block to be invoked when element method is called
#
- [:text_fields,
- :hidden_fields,
- :text_areas,
- :select_lists,
- :links,
- :checkboxes,
- :radio_buttons,
- :buttons,
- :divs,
- :spans,
- :tables,
- :cells,
- :images,
- :forms,
- :list_items,
- :unordered_lists,
- :ordered_lists,
- :h1s,
- :h2s,
- :h3s,
- :h4s,
- :h5s,
- :h6s,
- :paragraphs,
- :labels,
- :file_fields].each do |method_name|
- define_method(method_name) do |name, *identifier, &block|
+ idx = LocatorGenerator::ADVANCED_ELEMENTS.find_index { |type| type == :checkbox }
+ elements = LocatorGenerator::ADVANCED_ELEMENTS.clone
+ elements[idx] = :checkboxe
+ elements.each do |method_name|
+ define_method("#{method_name}s") do |name, *identifier, &block|
define_method("#{name}_elements") do
return call_block(&block) unless block.nil?
- platform_method = (method_name == :checkboxes) ? 'checkboxs_for' : "#{method_name.to_s}_for"
+ platform_method = (method_name == :checkboxe) ? 'checkboxs_for' : "#{method_name.to_s}s_for"
platform.send platform_method, (identifier.first ? identifier.first.clone : {})
end
end
end