Class: Capybara::PomPom::ElementFinder

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/capybara/pompom/element_finder.rb

Overview

Capybara::PomPom::ElementFinder

ElementFinder is used as a lambda to find elements when invoked by the Page instance rather than when defined.

Direct Known Subclasses

TableFinder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, locator, wrapper: nil) ⇒ ElementFinder

Initializes a new ElementFinder

Parameters

  • type: the capybara finder. E.g. find, find_link, etc…

  • locator: the locator used by capybara to find element.

  • wrapper (optional): an instance to wrap the found element in.



17
18
19
20
21
# File 'lib/capybara/pompom/element_finder.rb', line 17

def initialize(type, locator, wrapper: nil)
  @type = type
  @locator = locator
  @wrapper = wrapper
end

Instance Attribute Details

#locatorObject (readonly)

Returns the value of attribute locator.



9
10
11
# File 'lib/capybara/pompom/element_finder.rb', line 9

def locator
  @locator
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/capybara/pompom/element_finder.rb', line 9

def type
  @type
end

#wrapperObject (readonly)

Returns the value of attribute wrapper.



9
10
11
# File 'lib/capybara/pompom/element_finder.rb', line 9

def wrapper
  @wrapper
end

Instance Method Details

#get(scope = nil) ⇒ Object

Returns the Capybara::Element or wrapper if defined.



24
25
26
27
# File 'lib/capybara/pompom/element_finder.rb', line 24

def get(scope = nil)
  scope ||= self
  wrap_result(scope.send(type, locator))
end