Class: Capybara::PomPom::ElementFinder
- Inherits:
-
Object
- Object
- Capybara::PomPom::ElementFinder
- 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
Instance Attribute Summary collapse
-
#locator ⇒ Object
readonly
Returns the value of attribute locator.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Instance Method Summary collapse
-
#get(scope = nil) ⇒ Object
Returns the Capybara::Element or
wrapper
if defined. -
#initialize(type, locator, wrapper: nil) ⇒ ElementFinder
constructor
Initializes a new ElementFinder.
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
#locator ⇒ Object (readonly)
Returns the value of attribute locator.
9 10 11 |
# File 'lib/capybara/pompom/element_finder.rb', line 9 def locator @locator end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/capybara/pompom/element_finder.rb', line 9 def type @type end |
#wrapper ⇒ Object (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 |