Class: SitePrism::Section
- Inherits:
-
Object
- Object
- SitePrism::Section
- Extended by:
- Forwardable
- Includes:
- Capybara::DSL, DSL, ElementChecker, Loadable
- Defined in:
- lib/site_prism/section.rb
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) ⇒ Section
constructor
A new instance of Section.
- #native ⇒ Object
-
#page ⇒ Object
Capybara::DSL module “delegates” Capybara methods to the “page” method as such we need to overload this method so that the correct scoping occurs and calls within a section (For example section.find(element)) correctly scope to look within the section only.
- #parent_page ⇒ Object
- #visible? ⇒ Boolean
Methods included from DSL
Methods included from Loadable
included, #loaded?, #when_loaded
Methods included from ElementChecker
#all_there?, #elements_present
Constructor Details
#initialize(parent, root_element) ⇒ Section
Returns a new instance of Section.
28 29 30 31 32 |
# File 'lib/site_prism/section.rb', line 28 def initialize(parent, root_element) @parent = parent @root_element = root_element Capybara.within(@root_element) { yield(self) } if block_given? end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
13 14 15 |
# File 'lib/site_prism/section.rb', line 13 def parent @parent end |
#root_element ⇒ Object (readonly)
Returns the value of attribute root_element.
13 14 15 |
# File 'lib/site_prism/section.rb', line 13 def root_element @root_element end |
Class Method Details
.default_search_arguments ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/site_prism/section.rb', line 19 def self.default_search_arguments @default_search_arguments || ( superclass.respond_to?(:default_search_arguments) && superclass.default_search_arguments ) || nil end |
.set_default_search_arguments(*args) ⇒ Object
15 16 17 |
# File 'lib/site_prism/section.rb', line 15 def self.set_default_search_arguments(*args) @default_search_arguments = args end |
Instance Method Details
#capybara_session ⇒ Object
51 52 53 |
# File 'lib/site_prism/section.rb', line 51 def Capybara.current_session end |
#native ⇒ Object
61 62 63 |
# File 'lib/site_prism/section.rb', line 61 def native root_element.native end |
#page ⇒ Object
Capybara::DSL module “delegates” Capybara methods to the “page” method as such we need to overload this method so that the correct scoping occurs and calls within a section (For example section.find(element)) correctly scope to look within the section only
38 39 40 |
# File 'lib/site_prism/section.rb', line 38 def page root_element || super end |
#parent_page ⇒ Object
55 56 57 58 59 |
# File 'lib/site_prism/section.rb', line 55 def parent_page candidate = parent candidate = candidate.parent until candidate.is_a?(SitePrism::Page) candidate end |
#visible? ⇒ Boolean
42 43 44 |
# File 'lib/site_prism/section.rb', line 42 def visible? page.visible? end |