automation_object 0.0.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/automation_object.rb +14 -72
- data/lib/automation_object/blue_print.rb +37 -100
- data/lib/automation_object/blue_print/composite/automatic_onload_modal.rb +28 -0
- data/lib/automation_object/blue_print/composite/base.rb +18 -0
- data/lib/automation_object/blue_print/composite/custom_method.rb +23 -0
- data/lib/automation_object/blue_print/composite/element.rb +20 -0
- data/lib/automation_object/blue_print/composite/element_array.rb +21 -0
- data/lib/automation_object/blue_print/composite/element_hash.rb +26 -0
- data/lib/automation_object/blue_print/composite/helpers/element_helper.rb +33 -0
- data/lib/automation_object/blue_print/composite/helpers/multiple_elements_helper.rb +18 -0
- data/lib/automation_object/blue_print/composite/hook.rb +31 -0
- data/lib/automation_object/blue_print/composite/hook_action.rb +84 -0
- data/lib/automation_object/blue_print/composite/hook_element_requirements.rb +39 -0
- data/lib/automation_object/blue_print/composite/modal.rb +56 -0
- data/lib/automation_object/blue_print/composite/screen.rb +61 -0
- data/lib/automation_object/blue_print/composite/top.rb +51 -0
- data/lib/automation_object/blue_print/composite/view.rb +48 -0
- data/lib/automation_object/blue_print/hash_adapter.rb +17 -0
- data/lib/automation_object/blue_print/hash_adapter/automatic_onload_modal.rb +35 -0
- data/lib/automation_object/blue_print/hash_adapter/composite.rb +93 -0
- data/lib/automation_object/blue_print/hash_adapter/custom_method.rb +30 -0
- data/lib/automation_object/blue_print/hash_adapter/element.rb +34 -0
- data/lib/automation_object/blue_print/hash_adapter/element_array.rb +36 -0
- data/lib/automation_object/blue_print/hash_adapter/element_hash.rb +43 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/element_helper.rb +59 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/multiple_elements_helper.rb +35 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_error.rb +26 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb +99 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate.rb +23 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_allowed_keys.rb +31 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_element_presence_of.rb +55 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_instance_of.rb +39 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb +54 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_presence_of.rb +36 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_screen_presence_of.rb +55 -0
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_presence_of.rb +52 -0
- data/lib/automation_object/blue_print/hash_adapter/hook.rb +35 -0
- data/lib/automation_object/blue_print/hash_adapter/hook_action.rb +134 -0
- data/lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb +64 -0
- data/lib/automation_object/blue_print/hash_adapter/modal.rb +52 -0
- data/lib/automation_object/blue_print/hash_adapter/screen.rb +91 -0
- data/lib/automation_object/blue_print/hash_adapter/top.rb +63 -0
- data/lib/automation_object/blue_print/hash_adapter/view.rb +29 -0
- data/lib/automation_object/blue_print/helpers/file_helper.rb +38 -0
- data/lib/automation_object/blue_print/yaml_adapter.rb +50 -0
- data/lib/automation_object/driver.rb +44 -0
- data/lib/automation_object/driver/appium_adapter/driver.rb +150 -0
- data/lib/automation_object/driver/appium_adapter/element.rb +118 -0
- data/lib/automation_object/driver/base.rb +11 -0
- data/lib/automation_object/driver/driver.rb +69 -245
- data/lib/automation_object/driver/element.rb +51 -210
- data/lib/automation_object/driver/helpers/selenium_driver_helper.rb +41 -0
- data/lib/automation_object/driver/helpers/selenium_element_helper.rb +138 -0
- data/lib/automation_object/driver/nokogiri_adapter/backup/driver.rb +83 -0
- data/lib/automation_object/driver/nokogiri_adapter/backup/element.rb +66 -0
- data/lib/automation_object/driver/nokogiri_adapter/backup/form.rb +29 -0
- data/lib/automation_object/driver/nokogiri_adapter/backup/helpers/driver_element_helper.rb +52 -0
- data/lib/automation_object/driver/nokogiri_adapter/backup/session.rb +115 -0
- data/lib/automation_object/driver/nokogiri_adapter/driver.rb +104 -0
- data/lib/automation_object/driver/nokogiri_adapter/element.rb +85 -0
- data/lib/automation_object/driver/nokogiri_adapter/error.rb +17 -0
- data/lib/automation_object/driver/selenium_adapter/driver.rb +143 -0
- data/lib/automation_object/driver/selenium_adapter/element.rb +116 -0
- data/lib/automation_object/dsl.rb +33 -0
- data/lib/automation_object/dsl/blue_print_adapter.rb +16 -0
- data/lib/automation_object/dsl/blue_print_adapter/composite.rb +54 -0
- data/lib/automation_object/dsl/blue_print_adapter/element.rb +14 -0
- data/lib/automation_object/dsl/blue_print_adapter/element_array.rb +14 -0
- data/lib/automation_object/dsl/blue_print_adapter/element_hash.rb +14 -0
- data/lib/automation_object/dsl/blue_print_adapter/modal.rb +23 -0
- data/lib/automation_object/dsl/blue_print_adapter/screen.rb +26 -0
- data/lib/automation_object/dsl/blue_print_adapter/top.rb +19 -0
- data/lib/automation_object/dsl/models.rb +18 -0
- data/lib/automation_object/dsl/proxies/element.rb +16 -0
- data/lib/automation_object/dsl/proxies/element_array.rb +16 -0
- data/lib/automation_object/dsl/proxies/element_hash.rb +16 -0
- data/lib/automation_object/dsl/proxies/helpers/composite_helper.rb +74 -0
- data/lib/automation_object/dsl/proxies/modal.rb +17 -0
- data/lib/automation_object/dsl/proxies/screen.rb +17 -0
- data/lib/automation_object/dsl/proxies/top.rb +17 -0
- data/lib/automation_object/framework.rb +79 -386
- data/lib/automation_object/helpers/composite.rb +95 -0
- data/lib/automation_object/helpers/composite_hook.rb +46 -0
- data/lib/automation_object/helpers/hash.rb +15 -0
- data/lib/automation_object/helpers/reflection_helper.rb +28 -0
- data/lib/automation_object/helpers/string.rb +27 -0
- data/lib/automation_object/proxies/mutex_proxy.rb +63 -0
- data/lib/automation_object/proxies/proxy.rb +20 -0
- data/lib/automation_object/proxies/throttle_proxy.rb +57 -0
- data/lib/automation_object/state.rb +37 -0
- data/lib/automation_object/state/blue_print_adapter.rb +16 -0
- data/lib/automation_object/state/blue_print_adapter/composite.rb +65 -0
- data/lib/automation_object/state/blue_print_adapter/element.rb +20 -0
- data/lib/automation_object/state/blue_print_adapter/element_array.rb +25 -0
- data/lib/automation_object/state/blue_print_adapter/element_hash.rb +31 -0
- data/lib/automation_object/state/blue_print_adapter/element_proxy.rb +28 -0
- data/lib/automation_object/state/blue_print_adapter/helpers/element_helper.rb +31 -0
- data/lib/automation_object/state/blue_print_adapter/helpers/screen_manager.rb +137 -0
- data/lib/automation_object/state/blue_print_adapter/helpers/window.rb +39 -0
- data/lib/automation_object/state/blue_print_adapter/hook.rb +56 -0
- data/lib/automation_object/state/blue_print_adapter/hook_action.rb +33 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/action_loop.rb +35 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/change_screen.rb +26 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/change_to_previous_screen.rb +21 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_modal.rb +31 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_screen.rb +19 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/element_requirement.rb +34 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/new_screen.rb +37 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/possible_screen_changes.rb +21 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/reset_screen.rb +18 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/show_modal.rb +26 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/sleep.rb +18 -0
- data/lib/automation_object/state/blue_print_adapter/hook_actions/wait_for_elements.rb +20 -0
- data/lib/automation_object/state/blue_print_adapter/modal.rb +26 -0
- data/lib/automation_object/state/blue_print_adapter/screen.rb +32 -0
- data/lib/automation_object/state/blue_print_adapter/top.rb +45 -0
- data/lib/automation_object/state/error.rb +24 -0
- data/lib/automation_object/state/session.rb +38 -0
- data/lib/automation_object/step_definitions.rb +14 -0
- data/lib/automation_object/step_definitions/action.rb +21 -0
- data/lib/automation_object/step_definitions/cache.rb +23 -0
- data/lib/automation_object/step_definitions/element/actions.rb +87 -0
- data/lib/automation_object/step_definitions/element/regex.rb +24 -0
- data/lib/automation_object/step_definitions/element/steps.rb +67 -0
- data/lib/automation_object/step_definitions/parse.rb +39 -0
- data/lib/automation_object/version.rb +1 -1
- metadata +194 -110
- data/lib/automation_object/blue_print_validation/base_validation.rb +0 -44
- data/lib/automation_object/blue_print_validation/common_methods.rb +0 -106
- data/lib/automation_object/blue_print_validation/element_validation.rb +0 -198
- data/lib/automation_object/blue_print_validation/formatted_errors.rb +0 -41
- data/lib/automation_object/blue_print_validation/hook_validation.rb +0 -393
- data/lib/automation_object/blue_print_validation/key_value_constants.rb +0 -75
- data/lib/automation_object/blue_print_validation/modal_validation.rb +0 -37
- data/lib/automation_object/blue_print_validation/screen_modal_common_methods.rb +0 -119
- data/lib/automation_object/blue_print_validation/screen_validation.rb +0 -21
- data/lib/automation_object/blue_print_validation/validation_object.rb +0 -32
- data/lib/automation_object/driver/anonymous.rb +0 -27
- data/lib/automation_object/element/element.rb +0 -145
- data/lib/automation_object/element/element_array.rb +0 -12
- data/lib/automation_object/element/element_cell.rb +0 -126
- data/lib/automation_object/element/element_group.rb +0 -33
- data/lib/automation_object/element/element_hash.rb +0 -25
- data/lib/automation_object/element/element_helpers.rb +0 -29
- data/lib/automation_object/element/element_methods.rb +0 -134
- data/lib/automation_object/element/elements_helpers.rb +0 -204
- data/lib/automation_object/framework/events.rb +0 -8
- data/lib/automation_object/framework/helpers.rb +0 -101
- data/lib/automation_object/framework/print_objects.rb +0 -67
- data/lib/automation_object/framework/screen_monitor.rb +0 -55
- data/lib/automation_object/framework/screen_routing.rb +0 -310
- data/lib/automation_object/framework/window_helpers.rb +0 -181
- data/lib/automation_object/hash.rb +0 -6
- data/lib/automation_object/hook_helpers.rb +0 -27
- data/lib/automation_object/logger.rb +0 -179
- data/lib/automation_object/object.rb +0 -22
- data/lib/automation_object/screen/modal.rb +0 -8
- data/lib/automation_object/screen/screen.rb +0 -209
- data/lib/automation_object/screen/screen_hook_helpers.rb +0 -319
- data/lib/automation_object/screen/screen_modal_helpers.rb +0 -101
- data/lib/automation_object/screen/screen_prompt_helpers.rb +0 -21
- data/lib/automation_object/screen/screen_window_helpers.rb +0 -149
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module ScreenHookHelpers
|
|
3
|
-
def hook_listener(args)
|
|
4
|
-
self.hook(args[:configuration], args[:created_window_handle])
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def before_load
|
|
8
|
-
AutomationObject::Logger::add('Running Before Load Hook', [self.framework_location])
|
|
9
|
-
|
|
10
|
-
return unless self.configuration.has_key?('before_load')
|
|
11
|
-
unless self.configuration['before_load'].class == Hash
|
|
12
|
-
raise ArgumentError, "Expecting before_load in screen (#{self.screen_name}) to be a Hash"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
self.hook(self.configuration['before_load'])
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def hook(configuration, created_window_handle = false)
|
|
19
|
-
#Use each, allow for ordering of wait, change_screen in configuration
|
|
20
|
-
configuration.each { |key, value|
|
|
21
|
-
case key
|
|
22
|
-
when 'wait_for_new_window'
|
|
23
|
-
unless value == true
|
|
24
|
-
raise ArgumentError, "Only expecting the value of true for wait_for_new_window hook in screen (#{self.screen_name})"
|
|
25
|
-
end
|
|
26
|
-
created_window_handle = self.wait_for_new_window unless created_window_handle
|
|
27
|
-
when 'show_modal'
|
|
28
|
-
#Add modal to active modal, prevent multiple requests to do the same thing or error out
|
|
29
|
-
self.activate_modal(self.translate_string_to_class(value))
|
|
30
|
-
when 'close_window'
|
|
31
|
-
self.close_window(true) #Don't close the window, already closed
|
|
32
|
-
when 'change_screen'
|
|
33
|
-
screen_class_symbol = self.translate_string_to_class(value)
|
|
34
|
-
self.emit :change_screen, {
|
|
35
|
-
:screen_class_symbol => screen_class_symbol,
|
|
36
|
-
:created_window_handle => created_window_handle
|
|
37
|
-
}
|
|
38
|
-
when 'possible_screen_changes'
|
|
39
|
-
unless value.is_a?(Array)
|
|
40
|
-
raise ArgumentError, "Expected possible_screen_changes to be an Array in screen (#{self.screen_name})"
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
self.emit :possible_screen_changes, {
|
|
44
|
-
:possible_screens => value,
|
|
45
|
-
:created_window_handle => created_window_handle
|
|
46
|
-
}
|
|
47
|
-
when 'sleep'
|
|
48
|
-
sleep(value.to_f)
|
|
49
|
-
when 'wait_for_elements'
|
|
50
|
-
self.wait_for_elements(value)
|
|
51
|
-
when 'change_to_previous_screen'
|
|
52
|
-
self.emit :change_screen, {
|
|
53
|
-
:screen_class_symbol => self.framework_object.previous_screen_class,
|
|
54
|
-
:created_window_handle => created_window_handle
|
|
55
|
-
}
|
|
56
|
-
when 'close_modal'
|
|
57
|
-
self.active_modal = nil
|
|
58
|
-
when 'automatic_onload_modals'
|
|
59
|
-
self.automatic_onload_modals_hook(value)
|
|
60
|
-
when 'reset_screen'
|
|
61
|
-
self.reset_screen(true)
|
|
62
|
-
else
|
|
63
|
-
raise ArgumentError, "Hook requested (#{key}) is not implemented, found in screen #{self.screen_name}"
|
|
64
|
-
end
|
|
65
|
-
}
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def automatic_onload_modals_hook(configuration)
|
|
69
|
-
return unless configuration.class == Array
|
|
70
|
-
|
|
71
|
-
configuration.each { |modal_configuration|
|
|
72
|
-
next unless modal_configuration.class == Hash
|
|
73
|
-
next unless modal_configuration.has_key?('modal_name')
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if modal_configuration['number_of_checks']
|
|
77
|
-
number_of_checks = modal_configuration['number_of_checks'].to_i
|
|
78
|
-
else
|
|
79
|
-
number_of_checks = 10
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
number_of_checks.times do
|
|
83
|
-
modal_symbol = self.translate_string_to_class(modal_configuration['modal_name'])
|
|
84
|
-
if self.send(modal_symbol).live?
|
|
85
|
-
self.activate_modal(modal_symbol)
|
|
86
|
-
if modal_configuration['action'] == 'close'
|
|
87
|
-
self.close_modal(modal_symbol)
|
|
88
|
-
end
|
|
89
|
-
break
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
sleep(1)
|
|
93
|
-
end
|
|
94
|
-
}
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def wait_for_new_window
|
|
98
|
-
loops = 0
|
|
99
|
-
max_loops = 30
|
|
100
|
-
loop_sleep = 1
|
|
101
|
-
|
|
102
|
-
stored_window_handles = self.framework_object.current_screen_hash.keys
|
|
103
|
-
new_window_handle = nil
|
|
104
|
-
|
|
105
|
-
until new_window_handle
|
|
106
|
-
loops = loops + 1
|
|
107
|
-
if loops > max_loops
|
|
108
|
-
raise "Max loop breached waiting for new window in screen #{self.screen_name}"
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
window_handles = self.framework_object.get_window_handles.clone
|
|
112
|
-
window_handle_difference = window_handles.length - stored_window_handles.length
|
|
113
|
-
|
|
114
|
-
#Still waiting for new window
|
|
115
|
-
if window_handle_difference == 0
|
|
116
|
-
sleep(loop_sleep)
|
|
117
|
-
next
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
window_handle_difference = window_handles - stored_window_handles
|
|
121
|
-
|
|
122
|
-
#Throw error if more than one extra window, not sure which one to use
|
|
123
|
-
if window_handle_difference.length > 1
|
|
124
|
-
raise "More than one window was opened on an element action, found in screen #{self.screen_name}"
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
new_window_handle = window_handle_difference.shift
|
|
128
|
-
break
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
return new_window_handle
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def wait_for_elements(configuration)
|
|
135
|
-
unless configuration.class == Array
|
|
136
|
-
raise ArgumentError, "Expecting Array for wait_for_elements, got #{configuration.class} in screen #{self.screen_name}"
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
AutomationObject::Logger::add('Running Wait for Elements Hook', [self.framework_location])
|
|
140
|
-
|
|
141
|
-
configuration.each { |element_configuration|
|
|
142
|
-
unless element_configuration.class == Hash
|
|
143
|
-
raise ArgumentError, "Expecting wait_for_elements array to have Hash items got #{element_configuration.class} in screen #{self.screen_name}"
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
unless element_configuration.has_key?('element_name')
|
|
147
|
-
raise ArgumentError, "Expecting wait_for_elements array item hash to include the 'element_name' key in screen #{self.screen_name}"
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
element_name = element_configuration['element_name']
|
|
151
|
-
element_class_symbol = self.translate_string_to_class(element_name)
|
|
152
|
-
#Add exists? to requirements if it doesn't exist
|
|
153
|
-
unless element_configuration.has_key?('exists?')
|
|
154
|
-
unless self.send(element_class_symbol).configuration['multiple']
|
|
155
|
-
element_configuration['exists?'] = true
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
element_requirements = Hash.new
|
|
160
|
-
#Always put exists? at top if exists? is true
|
|
161
|
-
if element_configuration['exists?']
|
|
162
|
-
element_requirements['exists?'] = true
|
|
163
|
-
element_configuration.each { |key, value|
|
|
164
|
-
next if key == 'exists?' || key == 'element_name'
|
|
165
|
-
element_requirements[key] = value
|
|
166
|
-
}
|
|
167
|
-
else
|
|
168
|
-
element_configuration.each { |key, value|
|
|
169
|
-
next if key == 'element_name'
|
|
170
|
-
element_requirements[key] = value
|
|
171
|
-
}
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
self.wait_for_element(element_name, element_requirements)
|
|
175
|
-
}
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def wait_for_element(element_name, element_requirements)
|
|
179
|
-
AutomationObject::Logger::add('Running Wait for Element Hook', [self.framework_location])
|
|
180
|
-
|
|
181
|
-
element_class_symbol = self.translate_string_to_class(element_name)
|
|
182
|
-
|
|
183
|
-
unless self.respond_to?(element_class_symbol)
|
|
184
|
-
raise "Element class was not defined correctly in screen class (#{self.screen_name}) for element (#{element_name})"
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
element_requirements.each { |requirement, requirement_value|
|
|
188
|
-
requirement_symbol = requirement.to_s.to_sym
|
|
189
|
-
|
|
190
|
-
unless self.send(element_class_symbol).respond_to?(requirement_symbol)
|
|
191
|
-
raise ArgumentError, "Element (#{element_name}) in screen (#{self.screen_name}) does not have the method (#{requirement_symbol})"
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
requirement_success = false
|
|
195
|
-
|
|
196
|
-
loops = 0
|
|
197
|
-
until requirement_success
|
|
198
|
-
if self.send(element_class_symbol).is_multiple?
|
|
199
|
-
self.send(element_class_symbol).load_elements
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
element_value = self.send(element_class_symbol).send(requirement)
|
|
203
|
-
requirement_success = (element_value == requirement_value)
|
|
204
|
-
|
|
205
|
-
AutomationObject::Logger::add("Waiting for element method #{requirement} got: #{element_value}, expecting: #{requirement_value}", [self.framework_location])
|
|
206
|
-
|
|
207
|
-
sleep(1) if loops > 0
|
|
208
|
-
|
|
209
|
-
if loops > 30
|
|
210
|
-
raise "Element (#{element_name}) in screen (#{self.screen_name}) breached max wait loops for #{requirement}"
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
loops += 1
|
|
214
|
-
end
|
|
215
|
-
}
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
def has_live_configuration?
|
|
219
|
-
return false unless self.configuration.class == Hash
|
|
220
|
-
return false unless self.configuration['live?'].class == Hash
|
|
221
|
-
|
|
222
|
-
configuration = self.configuration['live?']
|
|
223
|
-
|
|
224
|
-
elements_array = Array.new
|
|
225
|
-
elements_array.push(configuration['element']) if configuration['element'].class == Hash
|
|
226
|
-
elements_array += configuration['elements'] if configuration['elements'].class == Array
|
|
227
|
-
|
|
228
|
-
return false if elements_array.length == 0 #No elements to check
|
|
229
|
-
|
|
230
|
-
true
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
def live?
|
|
234
|
-
AutomationObject::Logger::add('Checking if screen is live?', [self.framework_location])
|
|
235
|
-
|
|
236
|
-
#Make sure live? configuration is setup correctly, return false if not
|
|
237
|
-
return false unless self.has_live_configuration?
|
|
238
|
-
configuration = self.configuration['live?']
|
|
239
|
-
|
|
240
|
-
self.hook(configuration['before']) if configuration['before'].class == Hash
|
|
241
|
-
|
|
242
|
-
elements_array = Array.new
|
|
243
|
-
elements_array.push(configuration['element']) if configuration['element'].class == Hash
|
|
244
|
-
elements_array += configuration['elements'] if configuration['elements'].class == Array
|
|
245
|
-
|
|
246
|
-
elements_array.each { |element_configuration|
|
|
247
|
-
next unless element_configuration.class == Hash
|
|
248
|
-
element_requirements = element_configuration.clone
|
|
249
|
-
|
|
250
|
-
#Add element_name since is name conflicts with the Element Class method name()
|
|
251
|
-
if element_requirements['element_name']
|
|
252
|
-
element_name = element_requirements['element_name']
|
|
253
|
-
element_requirements.delete('element_name')
|
|
254
|
-
else
|
|
255
|
-
element_name = element_requirements['name']
|
|
256
|
-
element_requirements.delete('name')
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
unless element_name
|
|
260
|
-
raise "Need to define element name in live? configuration for screen (#{self.screen_name})"
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
element_class_symbol = self.translate_string_to_class(element_name)
|
|
264
|
-
|
|
265
|
-
unless element_class_symbol
|
|
266
|
-
raise "Element class symbol was not defined internally in screen (#{self.screen_name}) for element (#{element_name})"
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
unless self.respond_to?(element_class_symbol)
|
|
270
|
-
raise "Element class was not defined correctly in screen class (#{self.screen_name}) for element (#{element_name})"
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
#Always put exists? at top if exists? is true
|
|
274
|
-
#only for AutomationObject::Element
|
|
275
|
-
|
|
276
|
-
if self.send(element_class_symbol).class.is_a?(AutomationObject::Element)
|
|
277
|
-
modified_requirements = Hash.new
|
|
278
|
-
exists = true
|
|
279
|
-
exists = element_requirements['exists?'] if element_requirements.has_key?('exists?')
|
|
280
|
-
|
|
281
|
-
modified_requirements['exists?'] = exists
|
|
282
|
-
element_requirements.each { |key, value|
|
|
283
|
-
next if key == 'exists?'
|
|
284
|
-
modified_requirements[key] = value
|
|
285
|
-
}
|
|
286
|
-
else
|
|
287
|
-
modified_requirements = element_requirements
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
modified_requirements.each { |requirement, value|
|
|
291
|
-
requirement_symbol = requirement.to_s.to_sym
|
|
292
|
-
|
|
293
|
-
unless self.send(element_class_symbol).respond_to?(requirement_symbol)
|
|
294
|
-
raise ArgumentError, "Element (#{element_name}) in screen (#{self.screen_name}) does not have the method (#{requirement_symbol})"
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
#If no element error thrown then return live? false
|
|
298
|
-
# instead of throwing it through the whole program
|
|
299
|
-
begin
|
|
300
|
-
success = (self.send(element_name).send(requirement_symbol) == value)
|
|
301
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
|
302
|
-
return false
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
unless success
|
|
306
|
-
self.reset_screen
|
|
307
|
-
return false
|
|
308
|
-
end
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
self.hook(configuration['after']) if configuration['after'].class == Hash
|
|
313
|
-
|
|
314
|
-
#Reset screen parts, except window handle
|
|
315
|
-
self.reset_screen(true)
|
|
316
|
-
true
|
|
317
|
-
end
|
|
318
|
-
end
|
|
319
|
-
end
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module ScreenModalHelpers
|
|
3
|
-
def add_modals(params, configuration)
|
|
4
|
-
return unless configuration.class == Hash
|
|
5
|
-
|
|
6
|
-
configuration.each { |modal_name, modal_configuration|
|
|
7
|
-
modal_class_symbol = self.translate_string_to_class(modal_name)
|
|
8
|
-
|
|
9
|
-
setter = "#{modal_class_symbol}="
|
|
10
|
-
self.class.send(:attr_accessor, modal_class_symbol) unless respond_to?(setter)
|
|
11
|
-
|
|
12
|
-
params[:blue_prints] = modal_configuration
|
|
13
|
-
send setter, Modal.new(modal_name, params)
|
|
14
|
-
|
|
15
|
-
#Add emit listeners and relay from this screen out
|
|
16
|
-
#Add Listeners
|
|
17
|
-
this = self
|
|
18
|
-
self.send(modal_class_symbol).on :change_screen do |args|
|
|
19
|
-
this.emit :change_screen, {
|
|
20
|
-
:screen_class_symbol => args[:screen_class_symbol],
|
|
21
|
-
:created_window_handle => args[:created_window_handle]
|
|
22
|
-
}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
self.send(modal_class_symbol).on :close_window do |args|
|
|
26
|
-
this.emit :close_window, {
|
|
27
|
-
:screen_name => args[:screen_name],
|
|
28
|
-
:skip_close => args[:skip_close]
|
|
29
|
-
}
|
|
30
|
-
end
|
|
31
|
-
}
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
#Todo: modify show modal to be on all possible element methods, also add stuff for hide modal
|
|
35
|
-
def route_to_modal(modal_requested)
|
|
36
|
-
AutomationObject::Logger::add('Trying to route to modal', [self.framework_location])
|
|
37
|
-
|
|
38
|
-
use_element = nil
|
|
39
|
-
#Loop through all the elements and try to find "show_modal"
|
|
40
|
-
self.configuration['elements'] = Hash.new unless self.configuration['elements'].class == Hash
|
|
41
|
-
self.configuration['elements'].each { |element_name, element_configuration|
|
|
42
|
-
next unless element_configuration.class == Hash
|
|
43
|
-
next unless element_configuration['click'].class == Hash
|
|
44
|
-
next unless element_configuration['click']['after'].class == Hash
|
|
45
|
-
next unless element_configuration['click']['after']['show_modal']
|
|
46
|
-
next unless element_configuration['click']['after']['show_modal'].to_s == modal_requested.to_s
|
|
47
|
-
|
|
48
|
-
use_element = element_name
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
unless use_element
|
|
52
|
-
raise "Unable to route to modal #{modal_requested} in screen #{self.screen_name}, no element in screen has show modal for the requested modal"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
#Send the click request
|
|
56
|
-
self.send(use_element).click
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def activate_modal(modal_requested)
|
|
60
|
-
self.active_modal = modal_requested
|
|
61
|
-
self.send(modal_requested).before_load #Run before_load event
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def close_modal(modal_symbol)
|
|
65
|
-
unless self.active_modal == modal_symbol
|
|
66
|
-
raise "Expecting modal #{modal_symbol} to be active when requesting to close the modal."
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
modal_configuration = self.send(modal_symbol).configuration
|
|
70
|
-
|
|
71
|
-
unless modal_configuration.class == Hash
|
|
72
|
-
raise "Expecting modal #{modal_symbol} to have a Hash configuration, got: #{modal_configuration.class}"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
unless modal_configuration['elements'].class == Hash
|
|
76
|
-
raise "Expecting modal #{modal_symbol} -> elements to have a Hash configuration, got: #{modal_configuration['elements'].class}"
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
modal_elements = modal_configuration['elements']
|
|
80
|
-
modal_elements.each { |modal_element, element_value|
|
|
81
|
-
next unless element_value.class == Hash
|
|
82
|
-
|
|
83
|
-
element_value.each { |property_key, property_value|
|
|
84
|
-
next unless property_value.class == Hash
|
|
85
|
-
next unless property_value['after'].class == Hash
|
|
86
|
-
|
|
87
|
-
property_value['after'].each { |hook_key, hook_value|
|
|
88
|
-
next unless hook_key == 'close_modal'
|
|
89
|
-
next unless hook_value == true
|
|
90
|
-
|
|
91
|
-
self.send(modal_symbol).send(modal_element).send(property_key)
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
raise "Unable to close modal #{modal_symbol}, no elements found that would close the modal"
|
|
98
|
-
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module ScreenPromptHelpers
|
|
3
|
-
include AutomationObject::HookHelpers
|
|
4
|
-
|
|
5
|
-
def accept
|
|
6
|
-
AutomationObject::Logger::add('Accepting Alert Prompt', [self.framework_location])
|
|
7
|
-
|
|
8
|
-
self.do_hook_action('accept', 'before')
|
|
9
|
-
self.driver_object.accept_prompt
|
|
10
|
-
self.do_hook_action('accept', 'after')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def dismiss
|
|
14
|
-
AutomationObject::Logger::add('Dismissing Alert Prompt', [self.framework_location])
|
|
15
|
-
|
|
16
|
-
self.do_hook_action('dismiss', 'before')
|
|
17
|
-
self.driver_object.dismiss_prompt
|
|
18
|
-
self.do_hook_action('dismiss', 'after')
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module ScreenWindowHelpers
|
|
3
|
-
#in_iframe String, element_name that is the iframe
|
|
4
|
-
attr_accessor :in_iframe
|
|
5
|
-
|
|
6
|
-
def navigate_back
|
|
7
|
-
unless self.framework_object.screen_history_hash[self.window_handle].class == Array
|
|
8
|
-
raise ArgumentError, "Screen history hash doesn't contain window handle (#{self.window_handle}) for screen: #{self.screen_name}"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
history_array = self.framework_object.screen_history_hash[self.window_handle]
|
|
12
|
-
unless history_array.length > 1
|
|
13
|
-
raise ArgumentError, 'Cannot navigate back in the current window, nothing to go back to'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
#Remove last screen, which should be this one
|
|
17
|
-
history_array.pop
|
|
18
|
-
previous_screen_class = history_array.pop
|
|
19
|
-
|
|
20
|
-
self.driver_object.navigate.back
|
|
21
|
-
|
|
22
|
-
self.emit :change_screen, {
|
|
23
|
-
:screen_class_symbol => previous_screen_class
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def close_window(skip_close = false)
|
|
28
|
-
self.emit :close_window, {
|
|
29
|
-
:screen_name => self.screen_name,
|
|
30
|
-
:skip_close => skip_close
|
|
31
|
-
}
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def get_window_size
|
|
35
|
-
return self.driver_object.window_size if self.driver_object.respond_to?(:window_size)
|
|
36
|
-
return self.driver_object.manage.window.size
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def set_window_size(x, y)
|
|
40
|
-
self.driver_object.manage.window.resize_to(x, y)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def set_window_location(x, y)
|
|
44
|
-
self.driver_object.manage.window.move_to(x, y)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def maximize_window
|
|
48
|
-
self.driver_object.manage.window.maximize
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def current_url
|
|
52
|
-
return self.driver_object.current_url
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def hide_keyboard(close_key = nil)
|
|
56
|
-
unless self.framework_object.is_mobile?
|
|
57
|
-
raise 'This is not implemented for Browsers'
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
self.driver_object.hide_keyboard(close_key)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def screenshot(path)
|
|
64
|
-
unless path.match(/\.png$/)
|
|
65
|
-
raise ArgumentError, 'Screenshot path must contain .png file extension'
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
return self.driver_object.screenshot(path)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def window_in_iframe?
|
|
72
|
-
return (self.in_iframe) ? true : false
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def element_in_current_iframe?(element_name)
|
|
76
|
-
configuration = self.send(self.translate_string_to_class(element_name)).configuration
|
|
77
|
-
|
|
78
|
-
return false unless configuration.is_a?(Hash)
|
|
79
|
-
return false unless configuration.has_key?('in_iframe')
|
|
80
|
-
|
|
81
|
-
return (configuration['in_iframe'] == self.in_iframe)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def switch_to_default_content
|
|
85
|
-
return unless self.window_in_iframe?
|
|
86
|
-
|
|
87
|
-
AutomationObject::Logger::add('Switching from iframe to default content', {:screen_name => self.screen_name})
|
|
88
|
-
|
|
89
|
-
self.driver_object.switch_to.default_content
|
|
90
|
-
self.in_iframe = nil
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def switch_to_iframe(element_name)
|
|
94
|
-
configuration = self.send(self.translate_string_to_class(element_name)).configuration
|
|
95
|
-
iframe_element_name = configuration['in_iframe']
|
|
96
|
-
|
|
97
|
-
unless iframe_element_name.class == String
|
|
98
|
-
raise ArgumentError, "Expected String for in_iframe property of element (#{element_name}), screen (#{self.screen_name})"
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
iframe_element_object = self.get_element_object(iframe_element_name)
|
|
102
|
-
iframe_element_object.scroll_to_view
|
|
103
|
-
|
|
104
|
-
AutomationObject::Logger::add('Switching from default content to iframe', [self.framework_location])
|
|
105
|
-
iframe_element_object.switch_to_iframe
|
|
106
|
-
self.in_iframe = iframe_element_name
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def scroll_up
|
|
110
|
-
AutomationObject::Logger::add('Scrolling up', [self.framework_location])
|
|
111
|
-
|
|
112
|
-
self.do_hook_action('scroll_up', 'before')
|
|
113
|
-
driver_return = self.driver_object.execute_script('mobile: swipe', startX: 0.5, startY: 0.2, endX: 0.5, endY: 0.8, duration: 0.1)
|
|
114
|
-
self.do_hook_action('scroll_up', 'after')
|
|
115
|
-
|
|
116
|
-
return driver_return
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def scroll_down
|
|
120
|
-
AutomationObject::Logger::add('Scrolling down', [self.framework_location])
|
|
121
|
-
|
|
122
|
-
self.do_hook_action('scroll_down', 'before')
|
|
123
|
-
driver_return = self.driver_object.execute_script('mobile: swipe', startX: 0.5, startY: 0.8, endX: 0.5, endY: 0.2, duration: 0.1)
|
|
124
|
-
self.do_hook_action('scroll_down', 'after')
|
|
125
|
-
|
|
126
|
-
return driver_return
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def scroll_left
|
|
130
|
-
AutomationObject::Logger::add('Scrolling left', [self.framework_location])
|
|
131
|
-
|
|
132
|
-
self.do_hook_action('scroll_left', 'before')
|
|
133
|
-
driver_return = self.driver_object.execute_script('mobile: swipe', startX: 0.8, startY: 0.5, endX: 0.2, endY: 0.5, duration: 0.1)
|
|
134
|
-
self.do_hook_action('scroll_left', 'after')
|
|
135
|
-
|
|
136
|
-
return driver_return
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def scroll_right
|
|
140
|
-
AutomationObject::Logger::add('Scrolling right', [self.framework_location])
|
|
141
|
-
|
|
142
|
-
self.do_hook_action('scroll_right', 'before')
|
|
143
|
-
driver_return = self.driver_object.execute_script('mobile: swipe', startX: 0.2, startY: 0.5, endX: 0.8, endY: 0.5, duration: 0.1)
|
|
144
|
-
self.do_hook_action('scroll_right', 'after')
|
|
145
|
-
|
|
146
|
-
return driver_return
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|