Module: Druid::LocatorGenerator

Defined in:
lib/druid/locator_generator.rb

Constant Summary collapse

BASIC_ELEMENTS =
[:abbr,
:address,
:animate,
:animate_motion,
:animate_transform,
:article,
:as,
:aside,
:base,
:bdi,
:bdo,
:blockquote,
:body,
:br,
:caption,
:circle,
:cite,
:code,
:col,
:colgroup,
:command,
:cursor,
:data,
:datalist,
:dd,
:defs,
:del,
:desc,
:details,
:dfn,
:dialog,
:discard,
:dl,
:dt,
:ellipse,
:em,
:embed,
:fieldset,
:figcaption,
:figure,
:foot,
:footer,
:foreign_object,
:g,
:head,
:header,
:hgroup,
:hr,
:html,
:ins,
:kbd,
:keygen,
:legend,
:line,
:linear_gradient,
:main,
:map,
:mark,
:marker,
:menu,
:menuitem,
:mesh_gradient,
:mesh_patch,
:mesh_row,
:meta,
:metadata,
:meter,
:mpath,
:nav,
:noscript,
:object,
:optgroup,
:output,
:p,
:param,
:path,
:pattern,
:polygon,
:polyline,
:pre,
:progress,
:q,
:radial_gradient,
:rect,
:rp,
:rt,
:ruby,
:s,
:samp,
:script,
:section,
:small,
:source,
:stop,
:strong,
:style,
:sub,
:summary,
:sup,
:switch,
:symbol,
:template,
:text_path,
:thread,
:time,
:title,
:track,
:tspan,
:u,
:use,
:var,
:view,
:wbr]
ADVANCED_ELEMENTS =
[:text_field,
:hidden_field,
:text_area,
:select_list,
:link,
:checkbox,
:radio_button,
:button,
:div,
:span,
:table,
:cell,
:row,
:image,
:form,
:list_item,
:unordered_list,
:ordered_list,
:h1,
:h2,
:h3,
:h4,
:h5,
:h6,
:paragraph,
:label,
:file_field,
:area,
:canvas,
:audio,
:video,
:b,
:i,
:svg]

Class Method Summary collapse

Class Method Details

.generate_locators(target) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/druid/locator_generator.rb', line 153

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