Class: TestCentricity::PageManager

Inherits:
Object
  • Object
show all
Defined in:
lib/testcentricity_web.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#current_pageObject

Returns the value of attribute current_page.



35
36
37
# File 'lib/testcentricity_web.rb', line 35

def current_page
  @current_page
end

Class Method Details

.current_pagePageObject

Get the currently active PageObject

Examples:

active_page = TestCentricity::PageManager.current_page

Returns:



74
75
76
# File 'lib/testcentricity_web.rb', line 74

def self.current_page
  @current_page
end

.find_page(page_name) ⇒ Object



63
64
65
66
# File 'lib/testcentricity_web.rb', line 63

def self.find_page(page_name)
  (page_name.is_a? String) ? page_id = page_name.gsub(/\s+/, "").downcase.to_sym : page_id = page_name
  @page_objects[page_id]
end

.loaded?Boolean

Have all PageObjects been registered?

Examples:

TestCentricity::PageManager.loaded?

Returns:

  • (Boolean)

    true if all PageObjects have been registered



59
60
61
# File 'lib/testcentricity_web.rb', line 59

def self.loaded?
  not @page_objects.empty?
end

.register_page_objects(pages) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/testcentricity_web.rb', line 39

def self.register_page_objects(pages)
  result = ''
  pages.each do | page_object, page_class |
    obj = page_class.new
    @page_objects[page_object] = obj unless @page_objects.has_key?(page_object)
    page_key = obj.page_name.gsub(/\s+/, "").downcase.to_sym
    if page_key != page_object
      @page_objects[page_key] = obj unless @page_objects.has_key?(page_key)
    end
    result = "#{result}def #{page_object.to_s};@#{page_object.to_s} ||= TestCentricity::PageManager.find_page(:#{page_object.to_s});end;"
  end
  result
end

.set_current_page(page) ⇒ Object

Sets the currently active PageObject

Examples:

TestCentricity::PageManager.set_current_page(product_search_page)

Parameters:

  • page (PageObject)

    Reference to the active PageObject



84
85
86
# File 'lib/testcentricity_web.rb', line 84

def self.set_current_page(page)
  @current_page = page
end