Class: Capypage::Elements

Inherits:
Object
  • Object
show all
Includes:
ElementProxy, Enumerable
Defined in:
lib/capypage/elements.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_selector, child_selector, options = {}, &block) ⇒ Elements

Returns a new instance of Elements.



11
12
13
14
15
16
# File 'lib/capypage/elements.rb', line 11

def initialize(parent_selector, child_selector, options = {}, &block)
  @base_element   = Element.new(parent_selector, options)
  @child_selector = child_selector

  @child_dsl_block = block
end

Instance Attribute Details

#base_elementObject (readonly)

Returns the value of attribute base_element.



6
7
8
# File 'lib/capypage/elements.rb', line 6

def base_element
  @base_element
end

#child_dsl_blockObject (readonly)

Returns the value of attribute child_dsl_block.



6
7
8
# File 'lib/capypage/elements.rb', line 6

def child_dsl_block
  @child_dsl_block
end

#child_selectorObject (readonly)

Returns the value of attribute child_selector.



6
7
8
# File 'lib/capypage/elements.rb', line 6

def child_selector
  @child_selector
end

Instance Method Details

#find_by_index(index) ⇒ Object



22
23
24
# File 'lib/capypage/elements.rb', line 22

def find_by_index(index)
  Element.new("#{child_selector}:nth-child(#{index + 1})", finder_options, &child_dsl_block)
end

#find_by_text(text, options = {}) ⇒ Object



18
19
20
# File 'lib/capypage/elements.rb', line 18

def find_by_text(text, options = {})
  Element.new(child_selector, options.merge(finder_options(:text => text)), &child_dsl_block)
end