Module: Appom::ElementContainer::ClassMethods

Defined in:
lib/appom/element_container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mapped_itemsObject (readonly)

Returns the value of attribute mapped_items.



30
31
32
# File 'lib/appom/element_container.rb', line 30

def mapped_items
  @mapped_items
end

Instance Method Details

#add_to_mapped_items(item) ⇒ Object

Add item to @mapped_items array

Parameters:

  • item

    Item need to add



109
110
111
112
# File 'lib/appom/element_container.rb', line 109

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

#element(name, *find_args) ⇒ Object

Declare an element with name and args to find it

element :email, :accessibility_id, 'email_text_field'

appium.io/docs/en/commands/element/find-element/

Element doesn’t support block so that will raise if pass a block when declare

Parameters:

  • name

    Element name

  • *find_args

    An array contain information to find the element. It contains locator strategy and search target



44
45
46
47
48
49
50
51
52
53
# File 'lib/appom/element_container.rb', line 44

def element(name, *find_args)
  build_element(name, *find_args) do
    define_method(name) do |*runtime_args, &block|
      raise_if_block(self, name, !block.nil?, :element)
      _find(*merge_args(find_args, runtime_args))
    end

    create_get_element_params(name, find_args)
  end
end

#elements(name, *find_args) ⇒ Object

Declare an elements with name and args to find it

elements :contact_cell, :accessibility_id, 'contact_cell'

appium.io/docs/en/commands/element/find-element/

Elements doesn’t support block so that will raise if pass a block when declare

Parameters:

  • name

    Element name

  • *find_args

    An array contain information to find the elements. It contains locator strategy and search target



67
68
69
70
71
72
73
74
75
76
# File 'lib/appom/element_container.rb', line 67

def elements(name, *find_args)
  build_elements(name, *find_args) do
    define_method(name) do |*runtime_args, &block|
      raise_if_block(self, name, !block.nil?, :elements)
      _all(*merge_args(find_args, runtime_args))
    end

    create_get_element_params(name, find_args)
  end
end

#section(name, *args, &block) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/appom/element_container.rb', line 78

def section(name, *args, &block)
  section_class, find_args = extract_section_options(args, &block)
  build_element(name, *find_args) do
    define_method(name) do |*runtime_args, &block|
      section_element = _find(*merge_args(find_args, runtime_args))
      section_class.new(self, section_element)
    end

    create_get_element_params(name, find_args)
  end
end

#sections(name, *args, &block) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/appom/element_container.rb', line 90

def sections(name, *args, &block)
  section_class, find_args = extract_section_options(args, &block)
  build_sections(section_class, name, *find_args) do
    define_method(name) do |*runtime_args, &block|
      raise_if_block(self, name, !block.nil?, :sections)
      _all(*merge_args(find_args, runtime_args)).map do |element|
        section_class.new(self, element)
      end
    end

    create_get_element_params(name, find_args)
  end
end