Module: Appom::ElementContainer::ClassMethods
- Defined in:
- lib/appom/element_container.rb
Instance Attribute Summary collapse
-
#mapped_items ⇒ Object
readonly
Returns the value of attribute mapped_items.
Instance Method Summary collapse
-
#add_to_mapped_items(item) ⇒ Object
Add item to @mapped_items array.
-
#element(name, *find_args) ⇒ Object
Declare an element with name and args to find it.
-
#elements(name, *find_args) ⇒ Object
Declare an elements with name and args to find it.
- #section(name, *args, &block) ⇒ Object
- #sections(name, *args, &block) ⇒ Object
Instance Attribute Details
#mapped_items ⇒ Object (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
116 117 118 119 |
# File 'lib/appom/element_container.rb', line 116 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
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/appom/element_container.rb', line 44 def element(name, *find_args) args, text = deduce_element_args(find_args) build_element(name, *args) do define_method(name) do |*runtime_args, &block| raise_if_block(self, name, !block.nil?, :element) if text.nil? _find(*merge_args(args, runtime_args)) else find_element_has_text(text, *merge_args(args, runtime_args)) end end create_get_element_params(name, args) define_get_element_text(name, text) 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
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/appom/element_container.rb', line 74 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
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/appom/element_container.rb', line 85 def section(name, *args, &block) section_class, find_args = (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
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/appom/element_container.rb', line 97 def sections(name, *args, &block) section_class, find_args = (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 |