Class: SitePrism::Page
Instance Attribute Summary
#mapped_items
Attributes included from Loadable
#load_error, #loaded
Class Method Summary
collapse
Instance Method Summary
collapse
add_to_mapped_items, element, elements, iframe, raise_if_block, section, sections
Methods included from Loadable
included, #loaded?, #when_loaded
#all_there?
Class Method Details
.set_url(page_url) ⇒ Object
66
67
68
|
# File 'lib/site_prism/page.rb', line 66
def self.set_url(page_url)
@url = page_url.to_s
end
|
.set_url_matcher(page_url_matcher) ⇒ Object
70
71
72
|
# File 'lib/site_prism/page.rb', line 70
def self.set_url_matcher(page_url_matcher)
@url_matcher = page_url_matcher
end
|
.url ⇒ Object
74
75
76
|
# File 'lib/site_prism/page.rb', line 74
def self.url
@url
end
|
.url_matcher ⇒ Object
78
79
80
|
# File 'lib/site_prism/page.rb', line 78
def self.url_matcher
@url_matcher || url
end
|
Instance Method Details
#displayed?(*args) ⇒ Boolean
#load(expansion_or_html = {}, &block) ⇒ Object
Loads the page. Executes the block, if given, after running load validations on the page.
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/site_prism/page.rb', line 23
def load(expansion_or_html = {}, &block)
self.loaded = false
if expansion_or_html.is_a? String
@page = Capybara.string(expansion_or_html)
else
expanded_url = url(expansion_or_html)
raise SitePrism::NoUrlForPage if expanded_url.nil?
visit expanded_url
end
when_loaded(&block) if block_given?
end
|
#page ⇒ Object
14
15
16
|
# File 'lib/site_prism/page.rb', line 14
def page
@page || Capybara.current_session
end
|
#regexp_backed_matches ⇒ Object
58
59
60
|
# File 'lib/site_prism/page.rb', line 58
def regexp_backed_matches
url_matcher.match(page.current_url)
end
|
#secure? ⇒ Boolean
91
92
93
|
# File 'lib/site_prism/page.rb', line 91
def secure?
page.current_url.start_with? 'https'
end
|
#template_backed_matches ⇒ Object
62
63
64
|
# File 'lib/site_prism/page.rb', line 62
def template_backed_matches
matcher_template.mappings(page.current_url)
end
|
#url(expansion = {}) ⇒ Object
82
83
84
85
|
# File 'lib/site_prism/page.rb', line 82
def url(expansion = {})
return nil if self.class.url.nil?
Addressable::Template.new(self.class.url).expand(expansion).to_s
end
|
#url_matcher ⇒ Object
87
88
89
|
# File 'lib/site_prism/page.rb', line 87
def url_matcher
self.class.url_matcher
end
|
#url_matches(seconds = Waiter.default_wait_time) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/site_prism/page.rb', line 48
def url_matches(seconds = Waiter.default_wait_time)
return unless displayed?(seconds)
if url_matcher.is_a?(Regexp)
regexp_backed_matches
else
template_backed_matches
end
end
|