Module: Symbiont::Element

Included in:
Page, Region
Defined in:
lib/symbiont/capybara/element.rb

Instance Method Summary collapse

Instance Method Details

#element(name, *identifier) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/symbiont/capybara/element.rb', line 5

def element(name, *identifier)
  build(name, *identifier) do
    define_method(name.to_s) do |*options|
      find_first(*identifier, *options)
    end
  end
end

#elements(name, *identifier) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/symbiont/capybara/element.rb', line 13

def elements(name, *identifier)
  build(name, *identifier) do
    define_method(name.to_s) do |*options|
      find_all(*identifier, *options)
    end
  end
end

#region(name, *identifier, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/symbiont/capybara/element.rb', line 21

def region(name, *identifier, &block)
  region_class, region_args = extract_region_details(identifier, &block)

  build(name, *region_args) do
    define_method(name) do |*options|
      region_class.new(self, find_first(*region_args, *options))
    end
  end
end

#regions(name, *identifier, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/symbiont/capybara/element.rb', line 31

def regions(name, *identifier, &block)
  region_class, region_args = extract_region_details(identifier, &block)

  build(name, *region_args) do
    define_method(name) do |*options|
      find_all(*region_args, *options).map do |element|
        region_class.new(self, element)
      end
    end
  end
end