Method: PageObject::PageFactory#if_page

Defined in:
lib/page-object/page_factory.rb

#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.

Parameters:

  • a (PageObject, String)

    class that has included the PageObject module or a string containing the name of the class

  • Hash

    values that is pass through to page class a

  • an (block)

    optional block to be called

Returns:



91
92
93
94
95
# File 'lib/page-object/page_factory.rb', line 91

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