lib/page-object/locator_generator.rb in page-object-0.8.10 vs lib/page-object/locator_generator.rb in page-object-0.9.0
- old
+ new
@@ -1,85 +1,127 @@
module PageObject
module LocatorGenerator
+ BASIC_ELEMENTS = [:abbr,
+ :address,
+ :article,
+ :as,
+ :aside,
+ :bdi,
+ :bdo,
+ :blockquote,
+ :body,
+ :br,
+ :caption,
+ :cite,
+ :code,
+ :col,
+ :colgroup,
+ :command,
+ :data,
+ :datalist,
+ :dd,
+ :del,
+ :details,
+ :dfn,
+ :dialog,
+ :dl,
+ :dt,
+ :em,
+ :embed,
+ :fieldset,
+ :figcaption,
+ :figure,
+ :footer,
+ :head,
+ :header,
+ :hgroup,
+ :hr,
+ :ins,
+ :kbd,
+ :keygen,
+ :legend,
+ :map,
+ :mark,
+ :menu,
+ :meta,
+ :meter,
+ :nav,
+ :noscript,
+ :object,
+ :optgroup,
+ :output,
+ :param,
+ :pre,
+ :progress,
+ :rp,
+ :rt,
+ :ruby,
+ :samp,
+ :section,
+ :small,
+ :strong,
+ :style,
+ :sub,
+ :summary,
+ :sup,
+ :time,
+ :title,
+ :track,
+ :var,
+ :wbr]
+
+
+ ADVANCED_ELEMENTS = [:text_field,
+ :hidden_field,
+ :text_area,
+ :select_list,
+ :link,
+ :checkbox,
+ :radio_button,
+ :button,
+ :div,
+ :span,
+ :table,
+ :cell,
+ :image,
+ :form,
+ :list_item,
+ :ordered_list,
+ :unordered_list,
+ :h1,
+ :h2,
+ :h3,
+ :h4,
+ :h5,
+ :h6,
+ :paragraph,
+ :label,
+ :file_field,
+ :area,
+ :canvas,
+ :audio,
+ :video,
+ :svg]
+
def self.generate_locators(target)
- [:text_field,
- :hidden_field,
- :text_area,
- :select_list,
- :link,
- :checkbox,
- :radio_button,
- :button,
- :div,
- :span,
- :table,
- :cell,
- :image,
- :form,
- :list_item,
- :ordered_list,
- :unordered_list,
- :h1,
- :h2,
- :h3,
- :h4,
- :h5,
- :h6,
- :paragraph,
- :label,
- :file_field,
- :area,
- :canvas,
- :audio,
- :video,
- :svg].each do |tag|
+ ADVANCED_ELEMENTS.each do |tag|
target.send(:define_method, "#{tag.to_s}_element") do |*identifier|
@platform.send "#{tag.to_s}_for", locator(identifier)
end
target.send(:define_method, "#{tag.to_s}_elements") do |*identifier|
@platform.send("#{tag.to_s}s_for", identifier[0] ? identifier[0] : {})
end
end
- [: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 |tag|
+ BASIC_ELEMENTS.each do |tag|
target.send(:define_method, "#{tag.to_s}_element") do |*identifier|
- @platform.send :element_for, locator(identifier)
+ @platform.send :element_for, tag, locator(identifier)
end
target.send(:define_method, "#{tag.to_s}_elements") do |*identifier|
- @platform.send(:elements_for, identifier[0] ? identifier[0] : {})
+ @platform.send(:elements_for, tag, identifier[0] ? identifier[0] : {})
end
end
end
end