Module: Browsery::PageObjects::ElementContainer

Included in:
Base, Overlay::Base, Section, Widgets::Base
Defined in:
lib/browsery/page_objects/element_container.rb

Instance Method Summary collapse

Instance Method Details

#add_to_mapped_items(item) ⇒ Object



43
44
45
46
# File 'lib/browsery/page_objects/element_container.rb', line 43

def add_to_mapped_items(item)
  @mapped_items ||= []
  @mapped_items << item.to_s
end

#element(element_name, *find_args) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/browsery/page_objects/element_container.rb', line 5

def element(element_name, *find_args)
  build element_name, *find_args do |how, what|
    define_method element_name.to_s do
      find_first(how, what)
    end
  end
end

#elements(collection_name, *find_args) ⇒ Object Also known as: collection



13
14
15
16
17
18
19
# File 'lib/browsery/page_objects/element_container.rb', line 13

def elements(collection_name, *find_args)
  build collection_name, *find_args do |how, what|
    define_method collection_name.to_s do
      find_all(how, what)
    end
  end
end

#section(section_name, *args) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/browsery/page_objects/element_container.rb', line 22

def section(section_name, *args)
  section_class, find_args = extract_section_options args
  build section_name, *find_args do |how, what|
    define_method section_name do
      section_class.new self, find_first(how, what)
    end
  end
end

#sections(section_collection_name, *args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/browsery/page_objects/element_container.rb', line 31

def sections(section_collection_name, *args)
  section_class, find_args = extract_section_options args
  build section_collection_name, *find_args do
    define_method section_collection_name do
      self.class.raise_if_block(self, section_collection_name.to_s, !element_block.nil?)
      find_all(how, what).map do |element|
        section_class.new self, element
      end
    end
  end
end