Module: Druid::PageFactory
- Defined in:
- lib/druid/page_factory.rb
Overview
Module to facilitate to creating of page objects in step definitions. You can make the methods below available to all of your step definitions by adding this module to World. This idea was first discussed in Alister Scott’s blog entry watirmelon.com/2011/06/07/removing-local-page-references-from-cucumber-steps/.
Instance Method Summary collapse
-
#on_page(page_class, visit = false) {|@current_page| ... } ⇒ PageObject
Create a page object.
-
#visit_page(page_class, &block) ⇒ PageObject
attr_accessor :page.
Instance Method Details
#on_page(page_class, visit = false) {|@current_page| ... } ⇒ PageObject
Create a page object.
42 43 44 45 46 |
# File 'lib/druid/page_factory.rb', line 42 def on_page(page_class, visit=false, &block) @current_page = page_class.new(@driver, visit) yield @current_page if block_given? @current_page end |
#visit_page(page_class, &block) ⇒ PageObject
attr_accessor :page
Create and navigate to a page object. The navigation will only work if the ‘page_url’ method was call on the page object.
31 32 33 |
# File 'lib/druid/page_factory.rb', line 31 def visit_page(page_class, &block) on_page page_class, true, &block end |