Module: AppPrism::Sections::SectionFinders

Included in:
ScreenSection
Defined in:
lib/app_prism/sections/section_finders.rb

Instance Method Summary collapse

Instance Method Details

#screen_section(name, section_class, identifiers) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/app_prism/sections/section_finders.rb', line 8

def screen_section(name, section_class, identifiers)
  define_method(name) do
    if android?
      new_identifiers = identifiers[:android].clone
    elsif ios?
      new_identifiers = identifiers[:ios].clone
    else
      raise '' + 'OS is not specified. Please run tests with ANDROID=true or IOS=true' + ''
    end
    section_class.new(new_identifiers, @platform.driver)
  end

  define_method("#{name}_element") do
    get_element_for(identifiers)
  end

  define_method("#{name}?") do
    get_element_for(identifiers).visible?
  end

end

#screen_sections(name, section_class, identifiers) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/app_prism/sections/section_finders.rb', line 30

def screen_sections(name, section_class, identifiers)
  define_method(name) do
    sections_ary = AppPrism::Elements::ElementsCollection.new(identifiers, platform).map do |elt|
      section_class.new(elt.element, platform)
    end
    AppPrism::Sections::SectionsCollection[*sections_ary]
  end
end