Class: AePageObjects::Element
- Inherits:
-
Node
- Object
- Node
- AePageObjects::Element
show all
- Defined in:
- lib/ae_page_objects/element.rb
Constant Summary
Node::Methods::METHODS_TO_DELEGATE_TO_NODE
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Dsl
#collection, #element, #form_for, #inherited
#ensure_class_for_param!
#current_url, #current_url_without_params
#node, #stale?
#current_url, #current_url_without_params, #node
Constructor Details
#initialize(parent, options_or_locator = {}) ⇒ Element
Returns a new instance of Element.
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/ae_page_objects/element.rb', line 5
def initialize(parent, options_or_locator = {})
@parent = parent
@locator = nil
@name = nil
configure(parse_options(options_or_locator))
raise ArgumentError, ":name or :locator is required" unless @name || @locator
@locator ||= default_locator
super(scoped_node)
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
3
4
5
|
# File 'lib/ae_page_objects/element.rb', line 3
def parent
@parent
end
|
Instance Method Details
#__full_name__ ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/ae_page_objects/element.rb', line 39
def __full_name__
if parent.respond_to?(:__full_name__)
name_parts = [ parent.__full_name__, __name__ ].compact
if name_parts.empty?
nil
else
name_parts.join('_')
end
else
__name__
end
end
|
#__name__ ⇒ Object
56
57
58
|
# File 'lib/ae_page_objects/element.rb', line 56
def __name__
@name
end
|
#browser ⇒ Object
31
32
33
|
# File 'lib/ae_page_objects/element.rb', line 31
def browser
@browser ||= document.browser
end
|
#document ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/ae_page_objects/element.rb', line 19
def document
@document ||= begin
node = self.parent
until node.is_a?(::AePageObjects::Document)
node = node.parent
end
node
end
end
|
#full_name ⇒ Object
52
53
54
|
# File 'lib/ae_page_objects/element.rb', line 52
def full_name
__full_name__
end
|
#name ⇒ Object
60
61
62
|
# File 'lib/ae_page_objects/element.rb', line 60
def name
__name__
end
|
#to_s ⇒ Object
64
65
66
67
68
|
# File 'lib/ae_page_objects/element.rb', line 64
def to_s
super.tap do |str|
str << "@name:<#{@name}>; #@locator:<#{@locator}>"
end
end
|
#using_default_locator? ⇒ Boolean
70
71
72
|
# File 'lib/ae_page_objects/element.rb', line 70
def using_default_locator?
@locator == default_locator
end
|
#window ⇒ Object
35
36
37
|
# File 'lib/ae_page_objects/element.rb', line 35
def window
@window ||= document.window
end
|