automation_object 0.0.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,181 +0,0 @@
|
|
1
|
-
module AutomationObject
|
2
|
-
module FrameworkWindowHelpers
|
3
|
-
def get_window_handles
|
4
|
-
window_handles = Array.new
|
5
|
-
return window_handles unless self.is_browser?
|
6
|
-
|
7
|
-
unless self.is_mobile?
|
8
|
-
#Window handles for Selenium are simpler
|
9
|
-
return self.driver_object.window_handles
|
10
|
-
end
|
11
|
-
|
12
|
-
#Remove everything except the WEBVIEW
|
13
|
-
if self.driver_object.device_is_android?
|
14
|
-
window_handles = self.driver_object.window_handles
|
15
|
-
else
|
16
|
-
available_contexts = self.driver_object.available_contexts
|
17
|
-
available_contexts.each { |context|
|
18
|
-
window_handles.push(context) if context.match(/^WEBVIEW_\d+$/)
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
return window_handles
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_current_window_handle
|
26
|
-
#Selenium
|
27
|
-
unless self.is_mobile?
|
28
|
-
return self.driver_object.window_handle
|
29
|
-
end
|
30
|
-
|
31
|
-
#Appium
|
32
|
-
if self.driver_object.device_is_android?
|
33
|
-
return self.driver_object.window_handle
|
34
|
-
else
|
35
|
-
return self.driver_object.current_context
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def switch_to_window(window_handle)
|
40
|
-
unless self.is_mobile?
|
41
|
-
#Selenium
|
42
|
-
return self.driver_object.switch_to.window(window_handle)
|
43
|
-
end
|
44
|
-
|
45
|
-
#Appium
|
46
|
-
if self.driver_object.device_is_android?
|
47
|
-
return self.driver_object.switch_to.window(window_handle)
|
48
|
-
else
|
49
|
-
return self.driver_object.set_context(window_handle)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def check_closed_windows
|
54
|
-
window_handles = self.get_window_handles
|
55
|
-
|
56
|
-
self.current_screen_hash.each { |current_window_handle, current_screen_symbol|
|
57
|
-
next if window_handles.include?(current_window_handle)
|
58
|
-
|
59
|
-
#Delete current screen hash key
|
60
|
-
self.current_screen_hash.delete(current_window_handle)
|
61
|
-
self.reset_screen(current_screen_symbol)
|
62
|
-
self.previous_screen_hash.delete(current_window_handle)
|
63
|
-
|
64
|
-
if current_screen_symbol == self.current_screen_class
|
65
|
-
self.previous_screen_class = nil
|
66
|
-
end
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
def wait_for_window_load
|
71
|
-
AutomationObject::Logger::add('Waiting for window to load via document.readyState')
|
72
|
-
loops = 0
|
73
|
-
|
74
|
-
sleep(2)
|
75
|
-
until self.document_complete?
|
76
|
-
loops += 1
|
77
|
-
|
78
|
-
if loops > 30
|
79
|
-
break #Fuck it for now, just see what happens if we don't wait for this
|
80
|
-
raise Net::ReadTimeout, 'Error waiting too long for page to load'
|
81
|
-
end
|
82
|
-
|
83
|
-
sleep(3)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def document_complete?
|
88
|
-
AutomationObject::Logger::add('Running document_complete? command')
|
89
|
-
return self.driver_object.execute_script('return document.readyState;') == 'complete'
|
90
|
-
end
|
91
|
-
|
92
|
-
def wait_for_stable_body_size
|
93
|
-
AutomationObject::Logger::add('Going to wait for body element size to stabilize before continuing')
|
94
|
-
body_element_object = self.driver_object.find_element(:css, 'body')
|
95
|
-
|
96
|
-
begin
|
97
|
-
current_body_size = body_element_object.size
|
98
|
-
rescue Selenium::WebDriver::Error::StaleElementReferenceError, Errno::ECONNREFUSED
|
99
|
-
body_element_object = self.driver_object.find_element(:css, 'body')
|
100
|
-
current_body_size = body_element_object.size
|
101
|
-
end
|
102
|
-
|
103
|
-
previous_width = current_body_size[:width]
|
104
|
-
previous_height = current_body_size[:height]
|
105
|
-
|
106
|
-
sleep(2)
|
107
|
-
|
108
|
-
30.times do
|
109
|
-
sizes_string = "before: #{current_body_size[:width]}x#{current_body_size[:height]}"
|
110
|
-
|
111
|
-
begin
|
112
|
-
current_body_size = body_element_object.size
|
113
|
-
rescue Selenium::WebDriver::Error::StaleElementReferenceError, Errno::ECONNREFUSED
|
114
|
-
body_element_object = self.driver_object.find_element(:css, 'body')
|
115
|
-
current_body_size = body_element_object.size
|
116
|
-
end
|
117
|
-
|
118
|
-
if previous_width == current_body_size[:width] and previous_height == current_body_size[:height]
|
119
|
-
break
|
120
|
-
end
|
121
|
-
|
122
|
-
sizes_string << ", after: #{current_body_size[:width]}x#{current_body_size[:height]}"
|
123
|
-
AutomationObject::Logger::add("Running another loop for body size stabilization. #{sizes_string}")
|
124
|
-
|
125
|
-
previous_width = current_body_size[:width]
|
126
|
-
previous_height = current_body_size[:height]
|
127
|
-
|
128
|
-
sleep(2)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def set_window_size(x, y)
|
133
|
-
self.driver_object.manage.window.resize_to(x, y)
|
134
|
-
end
|
135
|
-
|
136
|
-
def close_window(screen_name, skip_close = false)
|
137
|
-
AutomationObject::Logger::add("Attempting to close window for screen #{screen_name}")
|
138
|
-
|
139
|
-
screen_class_symbol = self.translate_string_to_class(screen_name)
|
140
|
-
remove_current_handle = nil
|
141
|
-
|
142
|
-
self.current_screen_hash.each { |window_handle, current_screen_symbol|
|
143
|
-
next if current_screen_symbol != screen_class_symbol
|
144
|
-
remove_current_handle = window_handle
|
145
|
-
|
146
|
-
#Kill the thread
|
147
|
-
self.screen_monitor_thread.each { |key, thread|
|
148
|
-
next unless key == screen_class_symbol
|
149
|
-
break unless thread.class == Thread
|
150
|
-
Thread.kill(thread)
|
151
|
-
|
152
|
-
AutomationObject::Logger::add("Killed any threads belonging to window for screen #{screen_name}")
|
153
|
-
break
|
154
|
-
}
|
155
|
-
|
156
|
-
self.screen_monitor_thread[current_screen_symbol] = nil
|
157
|
-
|
158
|
-
#Close the window if needed
|
159
|
-
if skip_close == false
|
160
|
-
self.switch_to_window(window_handle)
|
161
|
-
self.driver_object.close
|
162
|
-
end
|
163
|
-
|
164
|
-
break
|
165
|
-
}
|
166
|
-
|
167
|
-
if remove_current_handle
|
168
|
-
self.current_screen_hash.delete(remove_current_handle)
|
169
|
-
self.screen_history_hash.delete(remove_current_handle)
|
170
|
-
end
|
171
|
-
|
172
|
-
self.current_screen_hash.each { |window_handle, current_screen_symbol|
|
173
|
-
self.switch_to_window(window_handle)
|
174
|
-
self.current_screen_class = current_screen_symbol
|
175
|
-
break
|
176
|
-
}
|
177
|
-
|
178
|
-
self.send(screen_class_symbol).reset_screen
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module AutomationObject
|
2
|
-
module HookHelpers
|
3
|
-
def do_hook_action(action, timing, created_window_handle = false)
|
4
|
-
self.before_mutex_lock if action == 'before'
|
5
|
-
|
6
|
-
#Return out if it doesn't meet the given requirements
|
7
|
-
return unless self.configuration.class == Hash
|
8
|
-
return unless self.configuration[action].class == Hash
|
9
|
-
return unless self.configuration[action][timing].class == Hash
|
10
|
-
|
11
|
-
hook_configuration = self.configuration[action][timing].clone
|
12
|
-
self.hook(hook_configuration, created_window_handle)
|
13
|
-
|
14
|
-
self.after_mutex_lock if action == 'after'
|
15
|
-
end
|
16
|
-
|
17
|
-
def before_mutex_lock
|
18
|
-
return unless Thread.current == Thread.main
|
19
|
-
self.framework_object.screen_monitor_mutex_object.lock
|
20
|
-
end
|
21
|
-
|
22
|
-
def after_mutex_lock
|
23
|
-
return unless Thread.current == Thread.main
|
24
|
-
self.framework_object.screen_monitor_mutex_object.unlock
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,179 +0,0 @@
|
|
1
|
-
module AutomationObject
|
2
|
-
class Logger
|
3
|
-
@@log = Array.new
|
4
|
-
|
5
|
-
@@output_message_caller_locations = false
|
6
|
-
@@output_driver_caller_locations = false
|
7
|
-
@@output_driver_element_caller_locations = false
|
8
|
-
|
9
|
-
def self.output_message_caller_locations
|
10
|
-
@@output_message_caller_locations
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.output_message_caller_locations=(value)
|
14
|
-
@@output_message_caller_locations = value
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.output_driver_caller_locations
|
18
|
-
@@output_driver_caller_locations
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.output_driver_caller_locations=(value)
|
22
|
-
@@output_driver_caller_locations = value
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.output_driver_element_caller_locations
|
26
|
-
@@output_driver_element_caller_locations
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.output_driver_element_caller_locations=(value)
|
30
|
-
@@output_driver_element_caller_locations = value
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.add(message, location = false)
|
34
|
-
called_locations = caller_locations
|
35
|
-
parsed_message = self::parse_message(message, called_locations, location)
|
36
|
-
|
37
|
-
@@log.push(parsed_message)
|
38
|
-
|
39
|
-
if AutomationObject::debug_mode
|
40
|
-
self::output_message(parsed_message)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.add_driver_message(total_time_taken, called_locations, method_symbol, *arguments, &block)
|
45
|
-
parsed_message = self::parse_driver_message(total_time_taken, called_locations, method_symbol, *arguments, &block)
|
46
|
-
|
47
|
-
@@log.push(parsed_message)
|
48
|
-
|
49
|
-
if AutomationObject::debug_mode
|
50
|
-
self::output_driver_message(parsed_message)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.add_driver_element_message(total_time_taken, called_locations, method_symbol, *arguments, &block)
|
55
|
-
parsed_message = self::parse_driver_element_message(total_time_taken, called_locations, method_symbol, *arguments, &block)
|
56
|
-
|
57
|
-
@@log.push(parsed_message)
|
58
|
-
|
59
|
-
if AutomationObject::debug_mode
|
60
|
-
self::output_driver_element_message(parsed_message)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.get_thread_message
|
65
|
-
return (Thread.main == Thread.current) ? 'main '.colorize(:black) : 'secondary '.colorize(:light_black)
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.parse_message(message, called_locations, location)
|
69
|
-
parsed_message = Hash.new
|
70
|
-
parsed_message[:message] = message.to_s
|
71
|
-
parsed_message[:called_locations] = called_locations
|
72
|
-
|
73
|
-
#Add which thread this is under
|
74
|
-
parsed_message[:thread_name] = self::get_thread_message
|
75
|
-
|
76
|
-
parsed_message[:location] = 'framework_object'
|
77
|
-
return parsed_message unless location.is_a?(Array)
|
78
|
-
|
79
|
-
parsed_message[:location] << '.'
|
80
|
-
location.each { |part|
|
81
|
-
parsed_message[:location] << part.to_s + '.'
|
82
|
-
}
|
83
|
-
parsed_message[:location].gsub!(/\.$/, '')
|
84
|
-
|
85
|
-
return parsed_message
|
86
|
-
end
|
87
|
-
|
88
|
-
def self.parse_driver_message(total_time_taken, called_locations, method_symbol, *arguments, &block)
|
89
|
-
parsed_message = Hash.new
|
90
|
-
parsed_message[:driver_message] = true
|
91
|
-
|
92
|
-
#Add which thread this is under
|
93
|
-
parsed_message[:thread_name] = self::get_thread_message
|
94
|
-
|
95
|
-
parsed_message[:total_time_taken] = total_time_taken.round(4)
|
96
|
-
parsed_message[:method_called] = method_symbol.to_s
|
97
|
-
parsed_message[:called_locations] = called_locations
|
98
|
-
|
99
|
-
parsed_message[:arguments] = arguments.to_s
|
100
|
-
parsed_message[:arguments] = parsed_message[:arguments].to_s
|
101
|
-
return parsed_message
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.parse_driver_element_message(total_time_taken, called_locations, method_symbol, *arguments, &block)
|
105
|
-
parsed_message = Hash.new
|
106
|
-
parsed_message[:driver_element_message] = true
|
107
|
-
|
108
|
-
#Add which thread this is under
|
109
|
-
parsed_message[:thread_name] = self::get_thread_message
|
110
|
-
|
111
|
-
parsed_message[:total_time_taken] = total_time_taken.round(4)
|
112
|
-
parsed_message[:method_called] = method_symbol.to_s
|
113
|
-
parsed_message[:called_locations] = called_locations
|
114
|
-
parsed_message[:arguments] = arguments.to_s
|
115
|
-
|
116
|
-
return parsed_message
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.format_object_name(object_name)
|
120
|
-
return false unless object_name
|
121
|
-
|
122
|
-
return object_name.to_s.gsub(/_class$/, '')
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.output_messages
|
126
|
-
@@log.each { |parsed_message|
|
127
|
-
self::output_message(parsed_message)
|
128
|
-
}
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.output_message(parsed_message)
|
132
|
-
return self::output_driver_message(parsed_message) if parsed_message[:driver_message]
|
133
|
-
return self::output_driver_element_message(parsed_message) if parsed_message[:driver_element_message]
|
134
|
-
|
135
|
-
output_string = 'debug: '.colorize(:black)
|
136
|
-
output_string << "thread: ".colorize(:cyan)
|
137
|
-
output_string << parsed_message[:thread_name]
|
138
|
-
output_string << "location: ".colorize(:cyan)
|
139
|
-
output_string << "#{parsed_message[:location]} "
|
140
|
-
output_string << "message: ".colorize(:cyan)
|
141
|
-
output_string << "#{parsed_message[:message]} "
|
142
|
-
|
143
|
-
Kernel.puts output_string #Just in case you're running under Cucumber
|
144
|
-
if self.output_message_caller_locations
|
145
|
-
Kernel.ap parsed_message[:called_locations] if parsed_message[:called_locations]
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def self.output_driver_message(parsed_message)
|
150
|
-
output_string = "driver call (#{parsed_message[:total_time_taken]} S): ".colorize(:light_black)
|
151
|
-
output_string << "thread: ".colorize(:cyan)
|
152
|
-
output_string << parsed_message[:thread_name]
|
153
|
-
output_string << "method: ".colorize(:cyan)
|
154
|
-
output_string << "#{parsed_message[:method_called]} "
|
155
|
-
output_string << "args: ".colorize(:cyan)
|
156
|
-
output_string << "#{parsed_message[:arguments]} "
|
157
|
-
|
158
|
-
Kernel.puts output_string #Just in case you're running under Cucumber
|
159
|
-
if self.output_driver_caller_locations
|
160
|
-
Kernel.ap parsed_message[:called_locations] if parsed_message[:called_locations]
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def self.output_driver_element_message(parsed_message)
|
165
|
-
output_string = "driver element call (#{parsed_message[:total_time_taken]} S): ".colorize(:light_black)
|
166
|
-
output_string << "thread: ".colorize(:cyan)
|
167
|
-
output_string << parsed_message[:thread_name]
|
168
|
-
output_string << "method: ".colorize(:cyan)
|
169
|
-
output_string << "#{parsed_message[:method_called]} "
|
170
|
-
output_string << "args: ".colorize(:cyan)
|
171
|
-
output_string << "#{parsed_message[:arguments]} "
|
172
|
-
|
173
|
-
Kernel.puts output_string #Just in case you're running under Cucumber
|
174
|
-
if self.output_driver_element_caller_locations
|
175
|
-
Kernel.ap parsed_message[:called_locations] if parsed_message[:called_locations]
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class ::Object
|
2
|
-
def translate_string_to_class(name)
|
3
|
-
name_string = name.to_s.gsub('=', '')
|
4
|
-
|
5
|
-
if name_string.match(/_class$/)
|
6
|
-
class_string = name_string
|
7
|
-
else
|
8
|
-
class_string = name_string + '_class'
|
9
|
-
end
|
10
|
-
|
11
|
-
class_string.to_sym
|
12
|
-
end
|
13
|
-
|
14
|
-
def translate_class_to_string(class_symbol)
|
15
|
-
class_symbol.to_s.gsub(/_class$/, '')
|
16
|
-
end
|
17
|
-
|
18
|
-
def translate_class_to_symbol(class_symbol)
|
19
|
-
class_string = class_symbol.to_s.gsub(/_class$/, '')
|
20
|
-
return class_string.to_sym
|
21
|
-
end
|
22
|
-
end
|
@@ -1,209 +0,0 @@
|
|
1
|
-
module AutomationObject
|
2
|
-
class Screen
|
3
|
-
include EventEmitter
|
4
|
-
|
5
|
-
include AutomationObject::ScreenWindowHelpers
|
6
|
-
include AutomationObject::ScreenHookHelpers
|
7
|
-
include AutomationObject::ScreenPromptHelpers
|
8
|
-
include AutomationObject::ScreenModalHelpers
|
9
|
-
|
10
|
-
attr_accessor :framework_object, :driver_object,
|
11
|
-
:configuration,
|
12
|
-
:framework_location,
|
13
|
-
:screen_name,
|
14
|
-
:active_modal,
|
15
|
-
:added_elements,
|
16
|
-
:element_storage,
|
17
|
-
:window_handle
|
18
|
-
|
19
|
-
def initialize(params)
|
20
|
-
self.added_elements = Array.new
|
21
|
-
self.element_storage = Hash.new
|
22
|
-
self.window_handle = nil
|
23
|
-
|
24
|
-
#Set params to properties
|
25
|
-
self.framework_object = params[:framework_object] || raise(ArgumentError, 'framework_object is required in params')
|
26
|
-
self.driver_object = params[:driver_object] || raise(ArgumentError, 'driver_object is required in params')
|
27
|
-
#Clone configuration, this will allow edit/deletes on different levels
|
28
|
-
params[:blue_prints] = Hash.new unless params[:blue_prints].class == Hash #Allow empty screen configs
|
29
|
-
self.configuration = params[:blue_prints].clone || raise(ArgumentError, 'configuration is required in params')
|
30
|
-
|
31
|
-
self.screen_name = params[:screen_name] || raise(ArgumentError, 'screen_name is required in params')
|
32
|
-
|
33
|
-
#Validate properties
|
34
|
-
raise ArgumentError, 'framework_object should be an Framework Object' unless self.framework_object.is_a? Framework
|
35
|
-
raise ArgumentError, 'configuration should be a Hash Object' unless self.configuration.is_a? Hash
|
36
|
-
raise ArgumentError, 'screen_name should be a String Object' unless self.screen_name.is_a? String
|
37
|
-
|
38
|
-
#Framework Location for Debugging
|
39
|
-
self.framework_location = self.screen_name
|
40
|
-
|
41
|
-
#Add Modals
|
42
|
-
self.add_modals(params, self.configuration['modals']) if self.configuration['modals'].is_a?(Hash)
|
43
|
-
|
44
|
-
#Add ElementGroups
|
45
|
-
self.add_element_groups(self.configuration['element_groups']) if self.configuration['element_groups'].is_a?(Hash)
|
46
|
-
|
47
|
-
#Add Elements
|
48
|
-
self.add_elements(self.configuration['elements']) if self.configuration['elements'].is_a?(Hash)
|
49
|
-
end
|
50
|
-
|
51
|
-
def respond_to?(method_symbol, include_private = false)
|
52
|
-
#Translate method in possible internal storage attribute
|
53
|
-
class_symbol = self.translate_string_to_class(method_symbol)
|
54
|
-
instance_symbol = class_symbol.to_s.gsub(/^@/, '')
|
55
|
-
instance_symbol = "@#{instance_symbol}".to_sym
|
56
|
-
|
57
|
-
self.instance_variables.each { |instance_variable|
|
58
|
-
return true if instance_variable == instance_symbol
|
59
|
-
}
|
60
|
-
|
61
|
-
#If not then do the super on the method_symbol
|
62
|
-
super.respond_to?(method_symbol, include_private)
|
63
|
-
end
|
64
|
-
|
65
|
-
def respond_to_element?(method_symbol, include_private = false)
|
66
|
-
element_symbol = self.translate_string_to_class(method_symbol)
|
67
|
-
instance_symbol = element_symbol.to_s.gsub(/^@/, '')
|
68
|
-
instance_symbol = "@#{instance_symbol}".to_sym
|
69
|
-
|
70
|
-
self.instance_variables.each { |instance_variable|
|
71
|
-
if instance_variable == instance_symbol
|
72
|
-
method_class = self.send(element_symbol).class
|
73
|
-
return ([Element, ElementHash, ElementArray, ElementGroup].include?(method_class))
|
74
|
-
end
|
75
|
-
}
|
76
|
-
|
77
|
-
return false
|
78
|
-
end
|
79
|
-
|
80
|
-
def method_missing(method_requested, *args, &block)
|
81
|
-
class_symbol = self.translate_string_to_class(method_requested)
|
82
|
-
|
83
|
-
unless self.respond_to?(class_symbol)
|
84
|
-
raise "Element or Modal (#{method_requested}) is not defined in screen object (#{self.screen_name})"
|
85
|
-
end
|
86
|
-
|
87
|
-
if self.window_in_iframe? and self.respond_to_element?(method_requested)
|
88
|
-
unless self.element_in_current_iframe?(method_requested)
|
89
|
-
self.switch_to_default_content
|
90
|
-
end
|
91
|
-
else
|
92
|
-
self.switch_to_default_content
|
93
|
-
end
|
94
|
-
|
95
|
-
#Preload elements for ElementHash/ElementArray
|
96
|
-
if self.send(class_symbol).class == ElementHash or self.send(class_symbol).class == ElementArray or self.send(class_symbol).class == ElementGroup
|
97
|
-
self.send(class_symbol).load_elements unless self.send(class_symbol).elements_loaded
|
98
|
-
end
|
99
|
-
|
100
|
-
#Load modal if needed
|
101
|
-
if self.send(class_symbol).class == Modal
|
102
|
-
#Skip opening the modal again if it's active
|
103
|
-
return self.send(class_symbol, *args, &block) if self.active_modal == class_symbol
|
104
|
-
|
105
|
-
#Try to make the modal active
|
106
|
-
self.route_to_modal(method_requested)
|
107
|
-
end
|
108
|
-
|
109
|
-
self.send(class_symbol, *args, &block)
|
110
|
-
end
|
111
|
-
|
112
|
-
def add_element_groups(configuration)
|
113
|
-
return unless configuration.is_a?(Hash)
|
114
|
-
|
115
|
-
configuration.each { |group_name, group_configuration|
|
116
|
-
group_class_name = self.translate_string_to_class(group_name)
|
117
|
-
|
118
|
-
setter = "#{group_class_name}="
|
119
|
-
self.class.send(:attr_accessor, group_class_name) unless self.respond_to?(setter)
|
120
|
-
|
121
|
-
group_object_options = {
|
122
|
-
:framework_object => self.framework_object,
|
123
|
-
:screen_object => self,
|
124
|
-
:driver_object => self.driver_object,
|
125
|
-
:blue_prints => group_configuration,
|
126
|
-
:screen_name => self.screen_name,
|
127
|
-
:element_name => group_name
|
128
|
-
}
|
129
|
-
|
130
|
-
send setter, AutomationObject::ElementGroup.new(group_object_options)
|
131
|
-
|
132
|
-
this = self
|
133
|
-
self.send(group_class_name).on :hook do |args|
|
134
|
-
this.hook_listener(args)
|
135
|
-
end
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
|
-
def add_elements(configuration)
|
140
|
-
return unless configuration.is_a?(Hash)
|
141
|
-
|
142
|
-
configuration.each { |element_name, element_configuration|
|
143
|
-
element_class_name = self.translate_string_to_class(element_name)
|
144
|
-
|
145
|
-
setter = "#{element_class_name}="
|
146
|
-
self.class.send(:attr_accessor, element_class_name) unless self.respond_to?(setter)
|
147
|
-
|
148
|
-
element_object_options = {
|
149
|
-
:framework_object => self.framework_object,
|
150
|
-
:screen_object => self,
|
151
|
-
:driver_object => self.driver_object,
|
152
|
-
:blue_prints => element_configuration,
|
153
|
-
:screen_name => self.screen_name,
|
154
|
-
:element_name => element_name
|
155
|
-
}
|
156
|
-
|
157
|
-
if element_configuration['multiple'] #Use element hash class for multiples
|
158
|
-
if element_configuration['define_elements_by']
|
159
|
-
send setter, AutomationObject::ElementHash.new(element_object_options)
|
160
|
-
else
|
161
|
-
send setter, AutomationObject::ElementArray.new(element_object_options)
|
162
|
-
end
|
163
|
-
else
|
164
|
-
send setter, AutomationObject::Element.new(element_object_options)
|
165
|
-
end
|
166
|
-
|
167
|
-
this = self
|
168
|
-
self.send(element_class_name).on :hook do |args|
|
169
|
-
this.hook_listener(args)
|
170
|
-
end
|
171
|
-
|
172
|
-
self.added_elements.push(element_class_name)
|
173
|
-
}
|
174
|
-
end
|
175
|
-
|
176
|
-
def reset_screen(skip_window_handle = false)
|
177
|
-
AutomationObject::Logger::add('Resetting screen', [self.framework_location])
|
178
|
-
|
179
|
-
self.switch_to_default_content
|
180
|
-
|
181
|
-
#Reset elements
|
182
|
-
self.added_elements.each { |added_element|
|
183
|
-
class_name = self.send(added_element).class.name
|
184
|
-
case class_name
|
185
|
-
when 'AutomationObject::ElementArray', 'AutomationObject::ElementHash', 'AutomationObject::ElementGroup'
|
186
|
-
self.send(added_element).reset_elements
|
187
|
-
when 'AutomationObject::Element'
|
188
|
-
self.send(added_element).reset_element
|
189
|
-
end
|
190
|
-
}
|
191
|
-
|
192
|
-
#Set active modal to nil
|
193
|
-
self.active_modal = nil
|
194
|
-
self.window_handle = nil unless skip_window_handle
|
195
|
-
end
|
196
|
-
|
197
|
-
def get_element_object(element_name)
|
198
|
-
unless self.respond_to?(element_name)
|
199
|
-
raise ArgumentError, "Element (#{element_name}) is not defined in the screen (#{self.screen_name})"
|
200
|
-
end
|
201
|
-
|
202
|
-
unless self.respond_to_element?(element_name)
|
203
|
-
raise ArgumentError, "Expected an element for iframe (#{element_name}) defined in screen (#{self.screen_name})"
|
204
|
-
end
|
205
|
-
|
206
|
-
return self.send(element_name)
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|