module Druid 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, :unordered_list, :ordered_list, :h1, :h2, :h3, :h4, :h5, :h6, :paragraph, :label, :file_field, :area, :canvas, :audio, :video, :svg] def self.generate_locators(target) ADVANCED_ELEMENTS.each do |tag| target.send(:define_method, "#{tag.to_s}_element") do |*identifier| self.send "#{tag.to_s}_for", locator(identifier).clone end target.send(:define_method, "#{tag.to_s}_elements") do |*identifier| self.send "#{tag.to_s}s_for", identifier[0] ? identifier[0].clone : {} end end BASIC_ELEMENTS.each do |tag| target.send(:define_method, "#{tag.to_s}_element") do |*identifier| self.send :element_for, tag, locator(identifier) end target.send(:define_method, "#{tag.to_s}_elements") do |*identifier| self.send(:elements_for, tag, identifier[0] ? identifier[0] : {}) end end end end end