Class: SitePrism::Section
- Inherits:
-
Object
- Object
- SitePrism::Section
- Extended by:
- Forwardable
- Includes:
- DSL, ElementChecker, Loadable
- Defined in:
- lib/site_prism/section.rb
Overview
- SitePrism::Section
-
SitePrism Sections are the mid level construct of the POM framework
Instances of this class represent a a part of a web page that can either sit inside a SitePrism::Page or sit inside another N sections, which then eventually will sit inside a page
All method calls made whilst on a page are scoped using ‘#to_capybara_node` which will be represented by the current `#root_element`. This is the locator for the section itself and is a mandatory argument
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#root_element ⇒ Object
readonly
Returns the value of attribute root_element.
Attributes included from Loadable
Class Method Summary collapse
Instance Method Summary collapse
- #capybara_session ⇒ Object
-
#initialize(parent, root_element, &block) ⇒ Section
constructor
A new instance of Section.
- #parent_page ⇒ Object
-
#to_capybara_node ⇒ Object
This scopes our calls inside Section correctly to the ‘Capybara::Node::Element`.
-
#within ⇒ Object
This allows us to return anything that’s passed in as a block to the section at creation time, so that an anonymous section or such-like will have the extra methods.
Methods included from DSL
Methods included from Loadable
included, #loaded?, #when_loaded
Methods included from ElementChecker
#all_there?, #elements_missing, #elements_present
Constructor Details
#initialize(parent, root_element, &block) ⇒ Section
Returns a new instance of Section.
43 44 45 46 47 |
# File 'lib/site_prism/section.rb', line 43 def initialize(parent, root_element, &block) @parent = parent @root_element = root_element within(&block) if block end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
19 20 21 |
# File 'lib/site_prism/section.rb', line 19 def parent @parent end |
#root_element ⇒ Object (readonly)
Returns the value of attribute root_element.
19 20 21 |
# File 'lib/site_prism/section.rb', line 19 def root_element @root_element end |
Class Method Details
.default_search_arguments ⇒ Object
26 27 28 29 30 |
# File 'lib/site_prism/section.rb', line 26 def default_search_arguments return @default_search_arguments if @default_search_arguments superclass.respond_to?(:default_search_arguments) && superclass.default_search_arguments end |
.set_default_search_arguments(*args) ⇒ Object
22 23 24 |
# File 'lib/site_prism/section.rb', line 22 def set_default_search_arguments(*args) @default_search_arguments = args end |
Instance Method Details
#capybara_session ⇒ Object
75 76 77 |
# File 'lib/site_prism/section.rb', line 75 def Capybara.current_session end |
#parent_page ⇒ Object
79 80 81 82 83 |
# File 'lib/site_prism/section.rb', line 79 def parent_page candidate = parent candidate = candidate.parent until candidate.is_a?(SitePrism::Page) candidate end |
#to_capybara_node ⇒ Object
This scopes our calls inside Section correctly to the ‘Capybara::Node::Element`
63 64 65 |
# File 'lib/site_prism/section.rb', line 63 def root_element end |
#within ⇒ Object
This allows us to return anything that’s passed in as a block to the section at creation time, so that an anonymous section or such-like will have the extra methods
This can also be used manually at runtime to allow people to abbreviate their calls
71 72 73 |
# File 'lib/site_prism/section.rb', line 71 def within Capybara.within(root_element) { yield(self) } end |