Module: PageObjectWrapper

Defined in:
lib/version.rb,
lib/page_object_wrapper.rb,
lib/page_object_wrapper/Dsl.rb,
lib/page_object_wrapper/Alias.rb,
lib/page_object_wrapper/Table.rb,
lib/page_object_wrapper/Action.rb,
lib/page_object_wrapper/Element.rb,
lib/page_object_wrapper/Validator.rb,
lib/page_object_wrapper/Exceptions.rb,
lib/page_object_wrapper/PageObject.rb,
lib/page_object_wrapper/Pagination.rb,
lib/page_object_wrapper/ElementsSet.rb,
lib/page_object_wrapper/known_elements.rb

Defined Under Namespace

Classes: Action, Alias, BrowserNotFound, DslElement, DslElementWithLocator, DynamicUrl, Element, ElementsSet, InvalidElement, InvalidPagination, Load, OutOfBoundsSubpage, PageObject, Pagination, Table, UnableToFeedObject, UnknownMenuType, UnknownPageObject, UnmappedPageObject, Validator

Constant Summary collapse

VERSION =
"1.6.1"
KNOWN_ELEMENTS =
[
  'a', 'abbr', 'abbrs', 'address', 'addresses', 'area', 
  'areas', 'article', 'articles', 'as', 'aside', 'asides', 
  'audio', 'audios', 'b', 'base', 'bases', 'bdi', 'bdis', 
  'bdo', 'bdos', 'blockquote', 'blockquotes', 'body', 'bodys', 
  'br', 'brs', 'bs', 'button', 'buttons', 'canvas', 'canvases', 
  'caption', 'captions', 'checkbox', 'checkboxes', 'cite', 
  'cites', 'code', 'codes', 'col', 'colgroup', 'colgroups', 
  'cols', 'command', 'commands', 'datalist', 'datalists', 
  'dd', 'dds', 'del', 'dels', 'details', 'dfn', 'dfns', 'div', 
  'divs', 'dl', 'dls', 'dt', 'dts', 'element',
  'em', 'embed', 'embeds', 'ems', 'fieldset', 'fieldsets', 'figcaption', 
  'figcaptions', 'figure', 'figures', 'file_field', 'file_fields', 'font', 
  'fonts', 'footer', 'footers', 'form', 'forms', 'frame', 'frames', 
  'h1', 'h1s', 'h2', 'h2s', 'h3', 'h3s', 'h4', 'h4s', 'h5', 'h5s', 'h6', 
  'h6s', 'head', 'header', 'headers', 'heads', 'hgroup', 'hgroups', 
  'hidden', 'hiddens', 'hr', 'hrs', 'html', 'htmls', 'i', 'iframe', 
  'iframes', 'img', 'imgs', 'input', 'inputs', 'ins', 'inses', 
  'is', 'kbd', 'kbds', 'keygen', 'keygens', 'label', 'labels', 'legend', 
  'legends', 'li', 'link', 'lis', 'map', 'maps', 'mark', 'marks', 'menu', 'menus', 
  'meta', 'metas', 'meter', 'meters', 'nav', 'navs', 'noscript', 'noscripts', 
  'object', 'objects', 'ol', 'ols', 'optgroup', 'optgroups', 'option', 'options', 
  'output', 'outputs', 'p', 'param', 'params', 'pre', 'pres', 'progress', 'progresses', 
  'ps', 'q', 'qs', 'radio', 'radios', 'rp', 'rps', 'rt', 'rts', 'rubies', 'ruby', 's', 
  'samp', 'samps', 'script', 'scripts', 'section', 'sections', 'select', 'selects', 'small', 
  'smalls', 'source', 'sources', 'span', 'spans', 'ss', 'strong', 'strongs', 'style', 'styles', 
  'sub', 'subs', 'summaries', 'summary', 'sup', 'sups', 'tbody', 'tbodys', 'td', 
  'tds', 'text_field', 'text_fields', 'textarea', 'textareas', 'tfoot', 'tfoots', 'th', 'thead', 
  'theads', 'ths', 'time', 'times', 'title', 'titles', 'tr', 'track', 'tracks', 'trs', 'ul', 
  'uls', 'var', 'vars', 'video', 'videos', 'wbr', 'wbrs'
]
@@domain =
nil
@@browser =
nil
@@current_page =
nil
@@current_result =
nil

Class Method Summary collapse

Class Method Details

.browserObject



23
24
25
# File 'lib/page_object_wrapper.rb', line 23

def self.browser
  @@browser
end

.current_pageObject



34
35
36
# File 'lib/page_object_wrapper.rb', line 34

def self.current_page
  @@current_page
end

.current_page=(page_object) ⇒ Object



38
39
40
# File 'lib/page_object_wrapper.rb', line 38

def self.current_page= page_object
  @@current_page = page_object
end

.current_page?(label) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/page_object_wrapper.rb', line 42

def self.current_page? label
  PageObject.map_current_page label
  true
end

.current_resultObject



51
52
53
# File 'lib/page_object_wrapper.rb', line 51

def self.current_result
  @@current_result
end

.current_result=(res) ⇒ Object



47
48
49
# File 'lib/page_object_wrapper.rb', line 47

def self.current_result= res
  @@current_result = res
end

.current_result?(post_processing, excpected_value) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/page_object_wrapper.rb', line 55

def self.current_result? post_processing, excpected_value
  real_value = @@current_result.instance_eval post_processing.to_s
  real_value == excpected_value
end

.define_page(label, &block) ⇒ Object



27
28
29
30
31
32
# File 'lib/page_object_wrapper.rb', line 27

def self.define_page(label, &block)
  page = PageObject.new(label)
  page.instance_eval(&block)
  PageObject.pages << page
  page
end

.domainObject



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

def self.domain
  @@domain
end

.domain=(val) ⇒ Object



12
13
14
# File 'lib/page_object_wrapper.rb', line 12

def self.domain=val
  @@domain=val
end

.load(path_to_pages = '.') ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/page_object_wrapper.rb', line 60

def self.load(path_to_pages='.')
  processed = 0
  Dir.glob("#{path_to_pages}/*.rb"){|fn|
    processed +=1
    require fn
  }
  raise PageObjectWrapper::Load, "No *.rb files found in #{path_to_pages}" if processed.zero?
  output = []
  PageObject.pages.each{|p|
    output += p.validate
  }
  raise PageObjectWrapper::Load, output.join if not output.empty?
end

.open_page(label, *args) ⇒ Object



82
83
84
85
# File 'lib/page_object_wrapper.rb', line 82

def self.open_page(label, *args)
  PageObject.open_page label, *args
  PageObject.map_current_page label
end

.receive_page(label) ⇒ Object



78
79
80
# File 'lib/page_object_wrapper.rb', line 78

def self.receive_page(label)
  PageObject.find_page_object(label)
end

.use_browser(b) ⇒ Object



16
17
18
19
20
21
# File 'lib/page_object_wrapper.rb', line 16

def self.use_browser b
  @@browser = b
  @@browser.class.send :define_method, :label_alias do |sym|
    # do nothing
  end
end