Class: AePageObjects::Collection
- Includes:
- Enumerable
- Defined in:
- lib/ae_page_objects/elements/collection.rb
Constant Summary
Constants inherited from Node
Node::METHODS_TO_DELEGATE_TO_NODE
Class Attribute Summary collapse
-
.item_class ⇒ Object
Returns the value of attribute item_class.
Instance Attribute Summary collapse
-
#item_locator ⇒ Object
readonly
Returns the value of attribute item_locator.
Attributes inherited from Element
Instance Method Summary collapse
- #[](index) ⇒ Object
- #at(index) ⇒ Object
- #each ⇒ Object
- #item_class ⇒ Object
- #last ⇒ Object
- #size ⇒ Object
Methods inherited from Element
#__full_name__, #__name__, #browser, #document, #full_name, #initialize, #name, #reload_ancestors, #to_s, #using_default_locator?, #window
Methods inherited from Node
current_url, #current_url, current_url_without_params, #current_url_without_params, #document, #element, #initialize, #node, #stale!, #stale?
Methods included from Dsl
#collection, #element, #element_attributes, #form_for, #inherited, #is_loaded, #is_loaded_blocks
Methods included from InternalHelpers
Constructor Details
This class inherits a constructor from AePageObjects::Element
Class Attribute Details
.item_class ⇒ Object
Returns the value of attribute item_class.
10 11 12 |
# File 'lib/ae_page_objects/elements/collection.rb', line 10 def item_class @item_class end |
Instance Attribute Details
#item_locator ⇒ Object (readonly)
Returns the value of attribute item_locator.
7 8 9 |
# File 'lib/ae_page_objects/elements/collection.rb', line 7 def item_locator @item_locator end |
Instance Method Details
#[](index) ⇒ Object
33 34 35 |
# File 'lib/ae_page_objects/elements/collection.rb', line 33 def [](index) at(index) end |
#at(index) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ae_page_objects/elements/collection.rb', line 25 def at(index) if index >= size || index < 0 nil else item_at(index) end end |
#each ⇒ Object
37 38 39 40 41 |
# File 'lib/ae_page_objects/elements/collection.rb', line 37 def each size.times do |index| yield item_at(index) end end |
#item_class ⇒ Object
20 21 22 |
# File 'lib/ae_page_objects/elements/collection.rb', line 20 def item_class self.class.item_class end |
#last ⇒ Object
59 60 61 |
# File 'lib/ae_page_objects/elements/collection.rb', line 59 def last self.at(size - 1) end |
#size ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ae_page_objects/elements/collection.rb', line 43 def size # # In some cases when #size is called while the DOM is updating, Capybara # will catch (and swallow) underlying exceptions such as # `Selenium::WebDriver::Error::StaleElementReferenceError`. # When this happens it will wait up to the max wait time, which can cause # issues for `AePageObjects.wait_until` blocks. # # To prevent this issue the #all and #size calls are made with the Capybara # wait time set to 0. # Capybara.using_wait_time(0) do node.all(:xpath, item_xpath, **).size end end |