Module: CapybaraPageObject::PageFactory
- Defined in:
- lib/capybara_page_object/page_factory.rb
Overview
Instance Method Summary collapse
-
#goto_page(page_class, params = {:using_params => {}}, &block) ⇒ PageObject
Create and navigate to a page object.
-
#new_page(page_class, params = {:using_params => {}}, visit = false, &block) ⇒ Object
Create a page object.
Instance Method Details
#goto_page(page_class, params = {:using_params => {}}, &block) ⇒ PageObject
Create and navigate to a page object. The navigation will only work if the ‘page_url’ method was set on the page object.
PageObject module or a string containing the name of the class available in the @params instance variable.
29 30 31 |
# File 'lib/capybara_page_object/page_factory.rb', line 29 def goto_page(page_class, params={:using_params => {}}, &block) new_page(page_class, params, true, &block) end |
#new_page(page_class, params = {:using_params => {}}, visit = false, &block) ⇒ Object
Create a page object.
36 37 38 39 40 41 42 43 |
# File 'lib/capybara_page_object/page_factory.rb', line 36 def new_page(page_class, params={:using_params => {}}, visit=false, &block) page_class = class_from_string(page_class) if page_class.is_a? String merged = page_class.params.merge(params[:using_params]) page_class.instance_variable_set("@merged_params", merged) unless merged.empty? @current_page = page_class.new(visit) block.call @current_page if block @current_page end |