Class: AePageObjects::Document
- Inherits:
-
Node
- Object
- Node
- AePageObjects::Document
show all
- Defined in:
- lib/ae_page_objects/document.rb
Constant Summary
Constants inherited
from Node
Node::METHODS_TO_DELEGATE_TO_NODE
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
current_url, #current_url, current_url_without_params, #current_url_without_params, #element, #node, #stale!, #stale?
Methods included from Dsl
#collection, #element, #element_attributes, #form_for, #inherited, #is_loaded, #is_loaded_blocks
#ensure_class_for_param!
Constructor Details
Returns a new instance of Document.
73
74
75
76
77
78
|
# File 'lib/ae_page_objects/document.rb', line 73
def initialize
super(Capybara.current_session)
@window = browser.current_window
@window.current_document = self
end
|
Class Attribute Details
.router ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/ae_page_objects/document.rb', line 6
def router
@router ||= begin
if [self, superclass].include?(Document)
AePageObjects.default_router
else
superclass.router
end
end
end
|
Instance Attribute Details
#window ⇒ Object
Returns the value of attribute window.
71
72
73
|
# File 'lib/ae_page_objects/document.rb', line 71
def window
@window
end
|
Class Method Details
.can_load_from_current_url? ⇒ Boolean
16
17
18
19
20
21
22
23
24
|
# File 'lib/ae_page_objects/document.rb', line 16
def can_load_from_current_url?
return true if paths.empty?
url = current_url_without_params
paths.any? do |path|
router.path_recognizes_url?(path, url)
end
end
|
.visit(*args) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ae_page_objects/document.rb', line 26
def visit(*args)
args = args.dup
inner_options = args.last.is_a?(::Hash)? args.last : {}
path = inner_options.delete(:via) || paths.first
full_path = router.generate_path(path, *args)
raise PathNotResolvable, "#{self.name} not visitable via #{paths.first}(#{args.inspect})" unless full_path
load_retries = 0
begin
Capybara.current_session.visit(full_path)
rescue Net::ReadTimeout
if load_retries < 3
load_retries += 1
retry
else
raise
end
end
new
end
|
Instance Method Details
#document ⇒ Object
84
85
86
|
# File 'lib/ae_page_objects/document.rb', line 84
def document
self
end
|
#reload(timeout: nil) ⇒ Object
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/ae_page_objects/document.rb', line 88
def reload(timeout: nil)
Capybara.current_session.driver.execute_script <<-SCRIPT
document.body.classList.add('ae_page_objects-reloading');
location.reload(true);
SCRIPT
element('body.ae_page_objects-reloading').wait_until_absent(timeout)
ensure_loaded!
self
end
|