Module: EDSL::PageObject::Visitation
- Includes:
- PageNavigation
- Defined in:
- lib/edsl/page_object/visitation.rb
Overview
Most of this is a semi-direct copy from PageObject::PageFactory
Class Method Summary collapse
Instance Method Summary collapse
-
#if_page(page_class, params = {:using_params => {}}, &block) ⇒ PageObject
(also: #if)
Create a page object if and only if the current page is the same page to be created.
- #on_current_page {|@@current_page| ... } ⇒ Object
-
#on_page(page_class, params = {:using_params => {}}, visit = false, &block) ⇒ Page
(also: #on)
Create a page object.
-
#visit_page(page_class, params = {:using_params => {}}, &block) ⇒ Page
(also: #visit)
Create and navigate to a page object.
Class Method Details
.current_page ⇒ Object
81 82 83 |
# File 'lib/edsl/page_object/visitation.rb', line 81 def self.current_page @@current_page end |
Instance Method Details
#if_page(page_class, params = {:using_params => {}}, &block) ⇒ PageObject Also known as: if
Create a page object if and only if the current page is the same page to be created
available in the @params instance variable.
102 103 104 105 106 |
# File 'lib/edsl/page_object/visitation.rb', line 102 def if_page(page_class, params={:using_params => {}},&block) page_class = class_from_string(page_class) if page_class.is_a? String return @@current_page unless @@current_page.class == page_class on_page(page_class, params, false, &block) end |
#on_current_page {|@@current_page| ... } ⇒ Object
88 89 90 91 |
# File 'lib/edsl/page_object/visitation.rb', line 88 def on_current_page(&block) yield @@current_page if block @@current_page end |
#on_page(page_class, params = {:using_params => {}}, visit = false, &block) ⇒ Page Also known as: on
Create a page object.
the @params instance variable.
71 72 73 74 75 76 77 78 79 |
# File 'lib/edsl/page_object/visitation.rb', line 71 def on_page(page_class, params={:using_params => {}}, visit=false, &block) page_class = class_from_string(page_class) if page_class.is_a? String return super(page_class, params, visit, &block) unless page_class.ancestors.include? Page merged = page_class.params.merge(params[:using_params]) page_class.instance_variable_set("@merged_params", merged) unless merged.empty? @@current_page = page_class.new(@browser, visit) block.call @@current_page if block @@current_page end |
#visit_page(page_class, params = {:using_params => {}}, &block) ⇒ Page Also known as: visit
Create and navigate to a page object. The navigation will only work if the ‘page_url’ method was call on the page object.
the @params instance variable.
53 54 55 |
# File 'lib/edsl/page_object/visitation.rb', line 53 def visit_page(page_class, params={:using_params => {}}, &block) on_page page_class, params, true, &block end |