Module: SitePrism::ElementContainer
Instance Attribute Summary collapse
-
#expected_items ⇒ Object
readonly
Returns the value of attribute expected_items.
-
#mapped_items ⇒ Object
readonly
Returns the value of attribute mapped_items.
Instance Method Summary collapse
- #add_to_mapped_items(item) ⇒ Object
- #element(element_name, *find_args) ⇒ Object
- #elements(collection_name, *find_args) ⇒ Object (also: #collection)
- #expected_elements(*elements) ⇒ Object
- #iframe(iframe_name, iframe_page_class, *args) ⇒ Object
- #raise_if_block(obj, name, has_block) ⇒ Object
- #section(section_name, *args, &block) ⇒ Object
- #sections(section_collection_name, *args, &block) ⇒ Object
Instance Attribute Details
#expected_items ⇒ Object (readonly)
Returns the value of attribute expected_items.
5 6 7 |
# File 'lib/site_prism/element_container.rb', line 5 def expected_items @expected_items end |
#mapped_items ⇒ Object (readonly)
Returns the value of attribute mapped_items.
5 6 7 |
# File 'lib/site_prism/element_container.rb', line 5 def mapped_items @mapped_items end |
Instance Method Details
#add_to_mapped_items(item) ⇒ Object
65 66 67 68 |
# File 'lib/site_prism/element_container.rb', line 65 def add_to_mapped_items(item) @mapped_items ||= [] @mapped_items << item end |
#element(element_name, *find_args) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/site_prism/element_container.rb', line 7 def element(element_name, *find_args) build element_name, *find_args do define_method element_name.to_s do |*runtime_args, &element_block| self.class.raise_if_block(self, element_name.to_s, !element_block.nil?) find_first(*find_args, *runtime_args) end end end |
#elements(collection_name, *find_args) ⇒ Object Also known as: collection
16 17 18 19 20 21 22 23 |
# File 'lib/site_prism/element_container.rb', line 16 def elements(collection_name, *find_args) build collection_name, *find_args do define_method collection_name.to_s do |*runtime_args, &element_block| self.class.raise_if_block(self, collection_name.to_s, !element_block.nil?) find_all(*find_args, *runtime_args) end end end |
#expected_elements(*elements) ⇒ Object
26 27 28 |
# File 'lib/site_prism/element_container.rb', line 26 def expected_elements(*elements) @expected_items = elements end |
#iframe(iframe_name, iframe_page_class, *args) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/site_prism/element_container.rb', line 51 def iframe(iframe_name, iframe_page_class, *args) element_find_args = deduce_iframe_element_find_args(args) scope_find_args = deduce_iframe_scope_find_args(args) add_to_mapped_items iframe_name create_existence_checker iframe_name, *element_find_args create_nonexistence_checker iframe_name, *element_find_args create_waiter iframe_name, *element_find_args define_method iframe_name do |&block| within_frame(*scope_find_args) do block.call iframe_page_class.new end end end |
#raise_if_block(obj, name, has_block) ⇒ Object
70 71 72 73 74 |
# File 'lib/site_prism/element_container.rb', line 70 def raise_if_block(obj, name, has_block) return unless has_block raise SitePrism::UnsupportedBlock, "#{obj.class}##{name}" end |
#section(section_name, *args, &block) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/site_prism/element_container.rb', line 30 def section(section_name, *args, &block) section_class, find_args = args, &block build section_name, *find_args do define_method section_name do |*runtime_args, &runtime_block| section_class.new self, find_first(*find_args, *runtime_args), &runtime_block end end end |
#sections(section_collection_name, *args, &block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/site_prism/element_container.rb', line 39 def sections(section_collection_name, *args, &block) section_class, find_args = args, &block build section_collection_name, *find_args do define_method section_collection_name do |*runtime_args, &element_block| self.class.raise_if_block(self, section_collection_name.to_s, !element_block.nil?) find_all(*find_args, *runtime_args).map do |element| section_class.new self, element end end end end |