Class: AePageObjects::ElementProxy
- Inherits:
-
Object
- Object
- AePageObjects::ElementProxy
show all
- Includes:
- PagePolling
- Defined in:
- lib/ae_page_objects/element_proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(element_class, *args) ⇒ ElementProxy
Returns a new instance of ElementProxy.
15
16
17
18
19
20
|
# File 'lib/ae_page_objects/element_proxy.rb', line 15
def initialize(element_class, *args)
@element_class = element_class
@args = args
@loaded_element = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/ae_page_objects/element_proxy.rb', line 100
def method_missing(name, *args, &block)
if name == :class
return @element_class
end
implicit_element.__send__(name, *args, &block)
end
|
Instance Method Details
#absent?(options = {}) ⇒ Boolean
43
44
45
46
47
48
|
# File 'lib/ae_page_objects/element_proxy.rb', line 43
def absent?(options = {})
wait_until_absent(options[:wait])
true
rescue ElementNotAbsent
false
end
|
#hidden?(options = {}) ⇒ Boolean
29
30
31
32
33
34
|
# File 'lib/ae_page_objects/element_proxy.rb', line 29
def hidden?(options = {})
wait_until_hidden(options[:wait])
true
rescue ElementNotHidden
false
end
|
#is_a?(type) ⇒ Boolean
92
93
94
|
# File 'lib/ae_page_objects/element_proxy.rb', line 92
def is_a?(type)
type == @element_class || type == ElementProxy
end
|
#kind_of?(type) ⇒ Boolean
96
97
98
|
# File 'lib/ae_page_objects/element_proxy.rb', line 96
def kind_of?(type)
is_a?(type)
end
|
#presence ⇒ Object
50
51
52
53
54
|
# File 'lib/ae_page_objects/element_proxy.rb', line 50
def presence
implicit_element
rescue LoadingElementFailed
nil
end
|
#present?(options = {}) ⇒ Boolean
36
37
38
39
40
41
|
# File 'lib/ae_page_objects/element_proxy.rb', line 36
def present?(options = {})
wait_until_present(options[:wait])
true
rescue ElementNotPresent
false
end
|
#respond_to?(*args) ⇒ Boolean
108
109
110
|
# File 'lib/ae_page_objects/element_proxy.rb', line 108
def respond_to?(*args)
super || @element_class.allocate.respond_to?(*args)
end
|
#visible?(options = {}) ⇒ Boolean
22
23
24
25
26
27
|
# File 'lib/ae_page_objects/element_proxy.rb', line 22
def visible?(options = {})
wait_until_visible(options[:wait])
true
rescue ElementNotVisible
false
end
|
#wait_until_absent(timeout = nil) ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/ae_page_objects/element_proxy.rb', line 83
def wait_until_absent(timeout = nil)
with_reloaded_element(timeout) do
@loaded_element.nil?
end
rescue AePageObjects::WaitTimeoutError
raise ElementNotAbsent, "element_class: #{@element_class}, options: #{@options.inspect}"
end
|
#wait_until_hidden(timeout = nil) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/ae_page_objects/element_proxy.rb', line 65
def wait_until_hidden(timeout = nil)
with_reloaded_element(timeout) do
@loaded_element.nil? || !@loaded_element.visible?
end
rescue AePageObjects::WaitTimeoutError
raise ElementNotHidden, "element_class: #{@element_class}, options: #{@options.inspect}"
end
|
#wait_until_present(timeout = nil) ⇒ Object
74
75
76
77
78
79
80
81
|
# File 'lib/ae_page_objects/element_proxy.rb', line 74
def wait_until_present(timeout = nil)
with_reloaded_element(timeout) do
!@loaded_element.nil?
end
rescue AePageObjects::WaitTimeoutError
raise ElementNotPresent, "element_class: #{@element_class}, options: #{@options.inspect}"
end
|
#wait_until_visible(timeout = nil) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/ae_page_objects/element_proxy.rb', line 56
def wait_until_visible(timeout = nil)
with_reloaded_element(timeout) do
!@loaded_element.nil? && @loaded_element.visible?
end
rescue AePageObjects::WaitTimeoutError
raise ElementNotVisible, "element_class: #{@element_class}, options: #{@options.inspect}"
end
|