Module: OperaWatir::Compat::ElementFinders

Defined in:
lib/operawatir/compat/element_finders.rb

Class Method Summary collapse

Class Method Details

.def_element(tag, plural, opts = {}, &blk) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/operawatir/compat/element_finders.rb', line 3

def self.def_element(tag, plural, opts={}, &blk)
  blk = block_given? ? blk : lambda {|selector| selector.tag tag}

  default_method = opts[:how] || :id

  define_method tag do |*arguments|
    OperaWatir::Collection.new(self).tap do |c|
      blk.call c.selector
      c.add_selector_from_arguments arguments, default_method
    end
  end

  define_method plural do |*arguments|
    OperaWatir::Collection.new(self).tap do |c|
      blk.call c.selector
    end
  end
end