Class: AePageObjects::ElementProxy
- Inherits:
-
Object
- Object
- AePageObjects::ElementProxy
show all
- 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.
11
12
13
14
15
16
|
# File 'lib/ae_page_objects/element_proxy.rb', line 11
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
96
97
98
99
100
101
102
|
# File 'lib/ae_page_objects/element_proxy.rb', line 96
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
39
40
41
42
43
44
|
# File 'lib/ae_page_objects/element_proxy.rb', line 39
def absent?(options = {})
wait_until_absent(options[:wait])
true
rescue ElementNotAbsent
false
end
|
#hidden?(options = {}) ⇒ Boolean
25
26
27
28
29
30
|
# File 'lib/ae_page_objects/element_proxy.rb', line 25
def hidden?(options = {})
wait_until_hidden(options[:wait])
true
rescue ElementNotHidden
false
end
|
#is_a?(type) ⇒ Boolean
88
89
90
|
# File 'lib/ae_page_objects/element_proxy.rb', line 88
def is_a?(type)
type == @element_class || type == ElementProxy
end
|
#kind_of?(type) ⇒ Boolean
92
93
94
|
# File 'lib/ae_page_objects/element_proxy.rb', line 92
def kind_of?(type)
is_a?(type)
end
|
#presence ⇒ Object
46
47
48
49
50
|
# File 'lib/ae_page_objects/element_proxy.rb', line 46
def presence
implicit_element
rescue LoadingElementFailed
nil
end
|
#present?(options = {}) ⇒ Boolean
32
33
34
35
36
37
|
# File 'lib/ae_page_objects/element_proxy.rb', line 32
def present?(options = {})
wait_until_present(options[:wait])
true
rescue ElementNotPresent
false
end
|
#respond_to?(*args) ⇒ Boolean
104
105
106
|
# File 'lib/ae_page_objects/element_proxy.rb', line 104
def respond_to?(*args)
super || @element_class.allocate.respond_to?(*args)
end
|
#visible?(options = {}) ⇒ Boolean
18
19
20
21
22
23
|
# File 'lib/ae_page_objects/element_proxy.rb', line 18
def visible?(options = {})
wait_until_visible(options[:wait])
true
rescue ElementNotVisible
false
end
|
#wait_until_absent(timeout = nil) ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/ae_page_objects/element_proxy.rb', line 79
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
61
62
63
64
65
66
67
68
|
# File 'lib/ae_page_objects/element_proxy.rb', line 61
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
70
71
72
73
74
75
76
77
|
# File 'lib/ae_page_objects/element_proxy.rb', line 70
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
52
53
54
55
56
57
58
59
|
# File 'lib/ae_page_objects/element_proxy.rb', line 52
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
|