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.



8
9
10
# File 'lib/appom/element_container.rb', line 8

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



67
68
69
70
# File 'lib/appom/element_container.rb', line 67

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 stratery and search target



32
33
34
35
36
37
38
39
# File 'lib/appom/element_container.rb', line 32

def element(name, *find_args)
  build(name, *find_args) do |*runtime_args, &block|
    raise_if_block(self, name, !block.nil?, :element)
    define_method(name) do
      find(*find_args)
    end
  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 stratery and search target



53
54
55
56
57
58
59
60
# File 'lib/appom/element_container.rb', line 53

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

#raise_if_block(obj, name, has_block, type) ⇒ Object

Raise if contain a block



11
12
13
14
15
16
17
18
# File 'lib/appom/element_container.rb', line 11

def raise_if_block(obj, name, has_block, type)
  return unless has_block

  puts "Type passed in: #{type}"
  puts "#{obj.class}##{name} does not accept blocks"

  raise Appom::UnsupportedBlockError
end