Class: AePageObjects::Node
- Inherits:
-
Object
- Object
- AePageObjects::Node
show all
- Extended by:
- Dsl
- Defined in:
- lib/ae_page_objects/node.rb
Constant Summary
collapse
- METHODS_TO_DELEGATE_TO_NODE =
[:find, :all, :value, :set, :text, :visible?]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Dsl
collection, form_for, inherited
#ensure_class_for_param!
Constructor Details
#initialize(capybara_node) ⇒ Node
Returns a new instance of Node.
17
18
19
20
21
22
|
# File 'lib/ae_page_objects/node.rb', line 17
def initialize(capybara_node)
@node = capybara_node
@stale = false
ensure_loaded!
end
|
Class Method Details
.current_url ⇒ Object
8
9
10
|
# File 'lib/ae_page_objects/node.rb', line 8
def current_url
Capybara.current_session.current_url.sub(/^https?:\/\/[^\/]*/, '')
end
|
.current_url_without_params ⇒ Object
12
13
14
|
# File 'lib/ae_page_objects/node.rb', line 12
def current_url_without_params
current_url.sub(/(\?|\#).*/, '')
end
|
Instance Method Details
#current_url ⇒ Object
44
45
46
|
# File 'lib/ae_page_objects/node.rb', line 44
def current_url
self.class.current_url
end
|
#current_url_without_params ⇒ Object
48
49
50
|
# File 'lib/ae_page_objects/node.rb', line 48
def current_url_without_params
self.class.current_url_without_params
end
|
#document ⇒ Object
40
41
42
|
# File 'lib/ae_page_objects/node.rb', line 40
def document
raise "Must implement!"
end
|
#element(options_or_locator) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/ae_page_objects/node.rb', line 63
def element(options_or_locator)
options = if options_or_locator.is_a?(Hash)
options_or_locator.dup
else
{:locator => options_or_locator}
end
element_class = options.delete(:is) || Element
ElementProxy.new(element_class, self, options)
end
|
#node ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/ae_page_objects/node.rb', line 24
def node
if stale?
raise StalePageObject, "Can't access stale page object '#{self}'"
end
@node
end
|
#stale! ⇒ Object
36
37
38
|
# File 'lib/ae_page_objects/node.rb', line 36
def stale!
@stale = true
end
|
#stale? ⇒ Boolean
32
33
34
|
# File 'lib/ae_page_objects/node.rb', line 32
def stale?
@stale
end
|