Class: AppPrism::Elements::ElementsCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/app_prism/elements/elements_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(identifiers, element_or_driver) ⇒ ElementsCollection

Returns a new instance of ElementsCollection.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/app_prism/elements/elements_collection.rb', line 6

def initialize(identifiers, element_or_driver)
  if identifiers.keys.include?(:android) || identifiers.keys.include?(:ios)
    @locator = identifiers[:android] if android?
    @locator = identifiers[:ios] if ios?
  else
    @locator = identifiers
  end

  @element_or_driver = element_or_driver
  @sel_elements  = @element_or_driver.find_elements(@locator) #maybe allow it to be empty if elements are not visible yet
  @elements = @sel_elements.map do |elt|
    AppPrism::Elements::Element.new(elt, @element_or_driver)
  end
end

Instance Method Details

#[](index) ⇒ Object



25
26
27
# File 'lib/app_prism/elements/elements_collection.rb', line 25

def [](index)
  @elements[index]
end

#each(&block) ⇒ Object



21
22
23
# File 'lib/app_prism/elements/elements_collection.rb', line 21

def each(&block)
  @elements.each(&block)
end