Module: Appom::ElementContainer::ClassMethods
- Defined in:
- lib/appom/element_container.rb
Overview
Class methods for defining page elements and sections
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) ⇒ Object
- #sections(name, *args, &block) ⇒ Object
Instance Attribute Details
#mapped_items ⇒ Object (readonly)
Returns the value of attribute mapped_items.
33 34 35 |
# File 'lib/appom/element_container.rb', line 33 def mapped_items @mapped_items end |
Instance Method Details
#add_to_mapped_items(item) ⇒ Object
Add item to @mapped_items array
120 121 122 123 |
# File 'lib/appom/element_container.rb', line 120 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
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/appom/element_container.rb', line 47 def element(name, *find_args) Appom::ElementValidation.validate_element_args(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
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/appom/element_container.rb', line 72 def elements(name, *find_args) Appom::ElementValidation.validate_element_args(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) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/appom/element_container.rb', line 85 def section(name, *args, &) Appom::ElementValidation.validate_section_args(name, *args) section_class, find_args = (args, &) build_element(name, *find_args) do define_method(name) do |*runtime_args| 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
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/appom/element_container.rb', line 99 def sections(name, *args, &block) Appom::ElementValidation.validate_section_args(name, *args) 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 |