Class: SitePrism::Section
- Inherits:
-
Object
- Object
- SitePrism::Section
- Extended by:
- ElementContainer
- Includes:
- Capybara::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 ElementContainer
#expected_items, #mapped_items
Attributes included from Loadable
Instance Method Summary collapse
- #evaluate_script(input) ⇒ Object
- #execute_script(input) ⇒ 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.
- #parent_page ⇒ Object
- #visible? ⇒ Boolean
Methods included from ElementContainer
add_to_mapped_items, element, elements, expected_elements, iframe, raise_if_block, section, sections
Methods included from Loadable
included, #loaded?, #when_loaded
Methods included from ElementChecker
Constructor Details
#initialize(parent, root_element) ⇒ Section
Returns a new instance of Section.
14 15 16 17 18 |
# File 'lib/site_prism/section.rb', line 14 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.
12 13 14 |
# File 'lib/site_prism/section.rb', line 12 def parent @parent end |
#root_element ⇒ Object (readonly)
Returns the value of attribute root_element.
12 13 14 |
# File 'lib/site_prism/section.rb', line 12 def root_element @root_element end |
Instance Method Details
#evaluate_script(input) ⇒ Object
33 34 35 |
# File 'lib/site_prism/section.rb', line 33 def evaluate_script(input) Capybara.current_session.evaluate_script(input) end |
#execute_script(input) ⇒ Object
29 30 31 |
# File 'lib/site_prism/section.rb', line 29 def execute_script(input) Capybara.current_session.execute_script(input) end |
#native ⇒ Object
45 46 47 |
# File 'lib/site_prism/section.rb', line 45 def native root_element.native end |
#page ⇒ Object
Capybara::DSL module “delegates” Capybara methods to the “page” method
21 22 23 |
# File 'lib/site_prism/section.rb', line 21 def page root_element || Capybara.current_session end |
#parent_page ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/site_prism/section.rb', line 37 def parent_page candidate_page = parent until candidate_page.is_a?(SitePrism::Page) candidate_page = candidate_page.parent end candidate_page end |
#visible? ⇒ Boolean
25 26 27 |
# File 'lib/site_prism/section.rb', line 25 def visible? page.visible? end |