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.
12
13
14
15
16
17
|
# File 'lib/ae_page_objects/element_proxy.rb', line 12
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
83
84
85
86
87
88
89
|
# File 'lib/ae_page_objects/element_proxy.rb', line 83
def method_missing(name, *args, &block)
if name == "class"
return @element_class
end
implicit_element.__send__(name, *args, &block)
end
|
Instance Method Details
#is_a?(type) ⇒ Boolean
75
76
77
|
# File 'lib/ae_page_objects/element_proxy.rb', line 75
def is_a?(type)
type == @element_class || type == ElementProxy
end
|
#kind_of?(type) ⇒ Boolean
79
80
81
|
# File 'lib/ae_page_objects/element_proxy.rb', line 79
def kind_of?(type)
is_a?(type)
end
|
#not_present? ⇒ Boolean
42
43
44
45
46
47
|
# File 'lib/ae_page_objects/element_proxy.rb', line 42
def not_present?
wait_for_absence
true
rescue ElementNotAbsent
false
end
|
#not_visible? ⇒ Boolean
28
29
30
31
32
33
|
# File 'lib/ae_page_objects/element_proxy.rb', line 28
def not_visible?
Waiter.wait_for do
inst = presence
inst.nil? || ! inst.visible?
end
end
|
#presence ⇒ Object
49
50
51
52
53
|
# File 'lib/ae_page_objects/element_proxy.rb', line 49
def presence
implicit_element
rescue LoadingElementFailed
nil
end
|
#present? ⇒ Boolean
35
36
37
38
39
40
|
# File 'lib/ae_page_objects/element_proxy.rb', line 35
def present?
wait_for_presence
true
rescue ElementNotPresent
false
end
|
#respond_to?(*args) ⇒ Boolean
91
92
93
|
# File 'lib/ae_page_objects/element_proxy.rb', line 91
def respond_to?(*args)
super || @element_class.allocate.respond_to?(*args)
end
|
#visible? ⇒ Boolean
Provided so that visible? can be asked without an explicit check for present? first.
21
22
23
24
25
26
|
# File 'lib/ae_page_objects/element_proxy.rb', line 21
def visible?
Waiter.wait_for do
inst = presence
!! inst && inst.visible?
end
end
|
#wait_for_absence(timeout = nil) ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'lib/ae_page_objects/element_proxy.rb', line 65
def wait_for_absence(timeout = nil)
is_absent = Waiter.wait_for(timeout) do
check_absence
end
unless is_absent
raise ElementNotAbsent, "element_class: #{@element_class}, options: #{@options.inspect}"
end
end
|
#wait_for_presence(timeout = nil) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/ae_page_objects/element_proxy.rb', line 55
def wait_for_presence(timeout = nil)
is_present = Waiter.wait_for(timeout) do
! presence.nil?
end
unless is_present
raise ElementNotPresent, "element_class: #{@element_class}, options: #{@options.inspect}"
end
end
|