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,101 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module FrameworkHelpers
|
|
3
|
-
attr_accessor :is_mobile, :is_browser, :supports_contexts
|
|
4
|
-
|
|
5
|
-
def is_mobile?
|
|
6
|
-
if self.is_mobile == nil
|
|
7
|
-
self.is_mobile = self.supports_contexts?
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
return self.is_mobile
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def is_browser?
|
|
14
|
-
unless self.is_browser == nil
|
|
15
|
-
return self.is_browser
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
#If Selenium the yeah we are using a browser
|
|
19
|
-
if self.supports_window_handles?
|
|
20
|
-
self.is_browser = true
|
|
21
|
-
return self.is_browser
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
#Now we need to check Appium's contexts to see if WEBVIEW is in available_contexts
|
|
25
|
-
available_contexts = self.driver_object.available_contexts
|
|
26
|
-
self.supports_contexts = true
|
|
27
|
-
|
|
28
|
-
available_contexts.each { |context|
|
|
29
|
-
if context.match(/^WEBVIEW_\d+$/)
|
|
30
|
-
self.is_browser = true
|
|
31
|
-
return self.is_browser
|
|
32
|
-
end
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
self.is_browser = false
|
|
36
|
-
return self.is_browser
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
#Selenium's use of window_handles
|
|
40
|
-
def supports_window_handles?
|
|
41
|
-
begin
|
|
42
|
-
self.driver_object.window_handles
|
|
43
|
-
return true
|
|
44
|
-
rescue NoMethodError, Selenium::WebDriver::Error::UnknownError
|
|
45
|
-
return false
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
#Appium's use of window_handles
|
|
50
|
-
def supports_contexts?
|
|
51
|
-
return self.supports_contexts if self.supports_contexts != nil
|
|
52
|
-
|
|
53
|
-
begin
|
|
54
|
-
self.driver_object.available_contexts
|
|
55
|
-
self.supports_contexts = true
|
|
56
|
-
return true
|
|
57
|
-
rescue NoMethodError
|
|
58
|
-
return false
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def current_screen
|
|
63
|
-
current_screen_object = Object.new
|
|
64
|
-
current_screen_object.class.module_eval { attr_accessor :framework_object }
|
|
65
|
-
current_screen_object.framework_object = self
|
|
66
|
-
|
|
67
|
-
def current_screen_object.method_missing(method_symbol, *args, &block)
|
|
68
|
-
return self.framework_object.send(self.framework_object.get_current_screen).send(method_symbol, *args, &block)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
current_screen_object
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def get_current_screen
|
|
75
|
-
return self.translate_class_to_string(self.current_screen_class).to_sym
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def kill_monitor_threads
|
|
79
|
-
begin
|
|
80
|
-
self.screen_monitor_thread.each_value { |thread|
|
|
81
|
-
Thread.kill(thread) if thread
|
|
82
|
-
}
|
|
83
|
-
rescue
|
|
84
|
-
# ignored
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def quit
|
|
89
|
-
AutomationObject::Logger::add('Quitting the framework')
|
|
90
|
-
self.kill_monitor_threads
|
|
91
|
-
|
|
92
|
-
if self.driver_object.respond_to?(:quit)
|
|
93
|
-
self.driver_object.quit if self.driver_object.respond_to?(:quit)
|
|
94
|
-
elsif self.driver_object.respond_to?(:driver_quit)
|
|
95
|
-
self.driver_object.driver_quit if self.driver_object.respond_to?(:driver_quit)
|
|
96
|
-
else
|
|
97
|
-
raise 'Unable to find provided driver quit method'
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module FrameworkPrintObjects
|
|
3
|
-
def print_objects(requested_screen_name = false)
|
|
4
|
-
puts 'Screens:'.colorize(:green)
|
|
5
|
-
|
|
6
|
-
self.instance_variables.each { |automation_variable|
|
|
7
|
-
automation_variable_value = self.instance_variable_get(automation_variable)
|
|
8
|
-
next unless automation_variable_value.class == Screen
|
|
9
|
-
|
|
10
|
-
screen_name = self.translate_class_to_string(automation_variable).gsub('@', '')
|
|
11
|
-
|
|
12
|
-
if requested_screen_name
|
|
13
|
-
next unless requested_screen_name == screen_name
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
screen_class_symbol = self.translate_string_to_class(screen_name)
|
|
17
|
-
|
|
18
|
-
puts "\t#{screen_name}".colorize(:blue)
|
|
19
|
-
|
|
20
|
-
self.send(screen_class_symbol).instance_variables.each { |screen_variable|
|
|
21
|
-
screen_object_name = self.translate_class_to_string(screen_variable).gsub('@', '')
|
|
22
|
-
screen_object_symbol = self.translate_string_to_class(screen_object_name)
|
|
23
|
-
|
|
24
|
-
output = "\t\t#{screen_object_name}".colorize(:magenta)
|
|
25
|
-
|
|
26
|
-
begin
|
|
27
|
-
object_class = self.send(screen_class_symbol).send(screen_object_symbol).class.to_s
|
|
28
|
-
case object_class
|
|
29
|
-
when 'AutomationObject::Element'
|
|
30
|
-
puts output + ' (Element)'.colorize(:green)
|
|
31
|
-
when 'AutomationObject::ElementHash'
|
|
32
|
-
puts output + ' (Element Hash)'.colorize(:red)
|
|
33
|
-
when 'AutomationObject::ElementArray'
|
|
34
|
-
puts output + ' (Element Array)'.colorize(:blue)
|
|
35
|
-
when 'AutomationObject::Modal'
|
|
36
|
-
puts output + ' (Modal)'.colorize(:cyan)
|
|
37
|
-
|
|
38
|
-
self.send(screen_class_symbol).send(screen_object_symbol).instance_variables.each { |modal_variable|
|
|
39
|
-
modal_object_name = self.translate_class_to_string(modal_variable).gsub('@', '')
|
|
40
|
-
modal_object_symbol = self.translate_string_to_class(modal_object_name)
|
|
41
|
-
|
|
42
|
-
modal_output = "\t\t\t#{modal_object_name}".colorize(:magenta)
|
|
43
|
-
#puts modal_output
|
|
44
|
-
begin
|
|
45
|
-
modal_object_class = self.send(screen_class_symbol).send(screen_object_symbol).send(modal_object_symbol).class.to_s
|
|
46
|
-
|
|
47
|
-
case modal_object_class
|
|
48
|
-
when 'AutomationObject::Element'
|
|
49
|
-
puts modal_output + ' (Element)'.colorize(:green)
|
|
50
|
-
when 'AutomationObject::ElementHash'
|
|
51
|
-
puts modal_output + ' (Element Hash)'.colorize(:red)
|
|
52
|
-
when 'AutomationObject::ElementArray'
|
|
53
|
-
puts modal_output + ' (Element Array)'.colorize(:blue)
|
|
54
|
-
end
|
|
55
|
-
rescue
|
|
56
|
-
next
|
|
57
|
-
end
|
|
58
|
-
}
|
|
59
|
-
end
|
|
60
|
-
rescue
|
|
61
|
-
next
|
|
62
|
-
end
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module FrameworkScreenMonitor
|
|
3
|
-
def screen_monitor_thread_method(screen_class_symbol)
|
|
4
|
-
Thread.abort_on_exception = true
|
|
5
|
-
|
|
6
|
-
auto_screens_array = self.send(screen_class_symbol).configuration['automatic_screen_changes']
|
|
7
|
-
unless auto_screens_array.is_a?(Array)
|
|
8
|
-
raise "Expecting #{screen_class_symbol} screen to have automatic_screen_changes as an Array"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
if auto_screens_array.length == 0
|
|
12
|
-
raise "Expecting #{screen_class_symbol} screen to have automatic_screen_changes count larger than 0"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
if self.previous_screen_class
|
|
16
|
-
if self.screen_monitor_thread[self.previous_screen_class].class == Thread
|
|
17
|
-
AutomationObject::Logger::add("Attempting to kill previous screen threads for screen #{self.previous_screen_class}")
|
|
18
|
-
|
|
19
|
-
previous_thread = self.screen_monitor_thread[self.previous_screen_class]
|
|
20
|
-
Thread.kill(previous_thread)
|
|
21
|
-
self.screen_monitor_thread[self.previous_screen_class] = nil
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
AutomationObject::Logger::add("Running thread listener for screen #{screen_class_symbol}")
|
|
26
|
-
|
|
27
|
-
possible_screen_change_symbol = nil
|
|
28
|
-
possible_screen_change_name = nil
|
|
29
|
-
|
|
30
|
-
screen_live = false
|
|
31
|
-
|
|
32
|
-
#Todo: window switching while checking for live?
|
|
33
|
-
until screen_live
|
|
34
|
-
self.screen_monitor_mutex_object.synchronize do
|
|
35
|
-
auto_screens_array.each { |possible_screen_change_name|
|
|
36
|
-
possible_screen_change_symbol = self.translate_string_to_class(possible_screen_change_name)
|
|
37
|
-
|
|
38
|
-
start_time = Time.now.to_f
|
|
39
|
-
screen_live = self.send(possible_screen_change_symbol).live?
|
|
40
|
-
end_time = Time.now.to_f
|
|
41
|
-
|
|
42
|
-
AutomationObject::Logger::add("Automatic screen check of #{possible_screen_change_name} took (#{end_time-start_time})S")
|
|
43
|
-
|
|
44
|
-
break if screen_live
|
|
45
|
-
}
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
if screen_live
|
|
50
|
-
AutomationObject::Logger::add("Automatic screen change to #{possible_screen_change_name} found")
|
|
51
|
-
self.set_current_screen(possible_screen_change_symbol)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
module AutomationObject
|
|
2
|
-
module FrameworkScreenRouting
|
|
3
|
-
def route_to_screen(from_screen, to_screen)
|
|
4
|
-
AutomationObject::Logger::add("Trying to automatically route to screen: #{to_screen}", [from_screen])
|
|
5
|
-
|
|
6
|
-
@from_screen = from_screen
|
|
7
|
-
@to_screen = to_screen
|
|
8
|
-
#Add @avoid_elements[screen_class_symbol].push(element_name),
|
|
9
|
-
#to be added later if elements are invisible or disabled
|
|
10
|
-
#Kind of a fail safe if elements are only sometimes disabled, try to find a new route after in this method if
|
|
11
|
-
#route found isn't working
|
|
12
|
-
@avoid_elements = Hash.new
|
|
13
|
-
@screen_map = self.map_screens
|
|
14
|
-
@route = nil
|
|
15
|
-
|
|
16
|
-
self.recursive_route_map
|
|
17
|
-
|
|
18
|
-
unless @route.class == Array
|
|
19
|
-
AutomationObject::Logger::add("Unable to find route to screen: #{to_screen}", [from_screen])
|
|
20
|
-
raise "Unable to find route between screen (#{@from_screen}) and screen (#{@to_screen})"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
route_found = self.execute_route(@route)
|
|
24
|
-
|
|
25
|
-
unless route_found
|
|
26
|
-
@from_screen = self.current_screen_class
|
|
27
|
-
@screen_map = self.map_screens
|
|
28
|
-
|
|
29
|
-
self.recursive_route_map
|
|
30
|
-
|
|
31
|
-
unless @route.class == Array
|
|
32
|
-
raise "Unable to find route between screen (#{@from_screen}) and screen (#{@to_screen})"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
self.execute_route(@route)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
#Reset these variables
|
|
39
|
-
@avoid_elements = nil
|
|
40
|
-
@from_screen = nil
|
|
41
|
-
@to_screen = nil
|
|
42
|
-
@screen_map = nil
|
|
43
|
-
@route = nil
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
#TODO, enable for all elements, will break except for click, accept, dismiss
|
|
47
|
-
def execute_route(route)
|
|
48
|
-
route.each { |direction|
|
|
49
|
-
screen_configuration = self.send(self.current_screen_class).configuration
|
|
50
|
-
|
|
51
|
-
if screen_configuration['accept'].class == Hash
|
|
52
|
-
possible_change_screen = self.find_possible_change_screen(screen_configuration['accept'])
|
|
53
|
-
if possible_change_screen == direction
|
|
54
|
-
self.send(self.current_screen_class).accept
|
|
55
|
-
next
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
if screen_configuration.has_key?('dismiss')
|
|
60
|
-
possible_change_screen = self.find_possible_change_screen(screen_configuration['dismiss'])
|
|
61
|
-
if possible_change_screen == direction
|
|
62
|
-
self.send(self.current_screen_class).dismiss
|
|
63
|
-
next
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
route_found = false
|
|
68
|
-
|
|
69
|
-
#Try modals
|
|
70
|
-
if screen_configuration['modals'].is_a?(Hash)
|
|
71
|
-
screen_configuration['modals'].each { |modal_name, modal_configuration|
|
|
72
|
-
next unless modal_configuration.is_a?(Hash)
|
|
73
|
-
next unless modal_configuration['elements'].is_a?(Hash)
|
|
74
|
-
|
|
75
|
-
modal_configuration['elements'].each { |element_name, element_configuration|
|
|
76
|
-
next unless element_configuration.class == Hash
|
|
77
|
-
next unless element_configuration['click'].class == Hash
|
|
78
|
-
|
|
79
|
-
possible_change_screen = self.find_possible_change_screen(element_configuration['click'])
|
|
80
|
-
if possible_change_screen == direction
|
|
81
|
-
#If the elements, don't work then don't use them
|
|
82
|
-
#Will implement method to try to find another way to the screen
|
|
83
|
-
element_object = self.send(self.current_screen_class).send(modal_name).send(element_name)
|
|
84
|
-
element_object = element_object.sample if element_object.class == ElementArray
|
|
85
|
-
element_object = element_object[element_object.keys.sample] if element_object.class == ElementHash
|
|
86
|
-
|
|
87
|
-
unless element_object.visible?
|
|
88
|
-
@avoid_elements[self.current_screen_class] = Array.new unless @avoid_elements[self.current_screen_class].class == Array
|
|
89
|
-
@avoid_elements[self.current_screen_class].push(element_name)
|
|
90
|
-
next
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
unless element_object.exists?
|
|
94
|
-
@avoid_elements[self.current_screen_class] = Array.new unless @avoid_elements[self.current_screen_class].class == Array
|
|
95
|
-
@avoid_elements[self.current_screen_class].push(element_name)
|
|
96
|
-
next
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
element_object.click
|
|
100
|
-
route_found = true
|
|
101
|
-
break #Stop from looping through other elements
|
|
102
|
-
end
|
|
103
|
-
}
|
|
104
|
-
break if route_found
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
next if route_found
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
next unless screen_configuration['elements'].class == Hash
|
|
111
|
-
|
|
112
|
-
screen_configuration['elements'].each { |element_name, element_configuration|
|
|
113
|
-
next unless element_configuration.class == Hash
|
|
114
|
-
next unless element_configuration['click'].class == Hash
|
|
115
|
-
|
|
116
|
-
possible_change_screen = self.find_possible_change_screen(element_configuration['click'])
|
|
117
|
-
if possible_change_screen == direction
|
|
118
|
-
#If the elements, don't work then don't use them
|
|
119
|
-
#Will implement method to try to find another way to the screen
|
|
120
|
-
element_object = self.send(self.current_screen_class).send(element_name)
|
|
121
|
-
element_object = element_object.sample if element_object.class == ElementArray
|
|
122
|
-
element_object = element_object[element_object.keys.sample] if element_object.class == ElementHash
|
|
123
|
-
|
|
124
|
-
unless element_object.visible?
|
|
125
|
-
@avoid_elements[self.current_screen_class] = Array.new unless @avoid_elements[self.current_screen_class].class == Array
|
|
126
|
-
@avoid_elements[self.current_screen_class].push(element_name)
|
|
127
|
-
next
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
unless element_object.exists?
|
|
131
|
-
@avoid_elements[self.current_screen_class] = Array.new unless @avoid_elements[self.current_screen_class].class == Array
|
|
132
|
-
@avoid_elements[self.current_screen_class].push(element_name)
|
|
133
|
-
next
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
element_object.click
|
|
137
|
-
route_found = true
|
|
138
|
-
break #Stop from looping through other elements
|
|
139
|
-
end
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return route_found unless route_found
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
true
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def recursive_route_map
|
|
149
|
-
@depth = 0 unless @depth.class == Fixnum
|
|
150
|
-
@routes_array = Array.new unless @routes_array
|
|
151
|
-
|
|
152
|
-
#Get where we are and start there adding every possible direction to start with
|
|
153
|
-
if @depth == 0
|
|
154
|
-
@screen_map[@from_screen].each { |possible_direction|
|
|
155
|
-
new_route = Array.new
|
|
156
|
-
new_route.push(possible_direction)
|
|
157
|
-
@routes_array.push(new_route)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
@depth += 1
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
#Better Check
|
|
164
|
-
#Do validation of @routes_array find if route found and break out
|
|
165
|
-
@routes_array.each { |route|
|
|
166
|
-
#Get the last direction and see if its the destination
|
|
167
|
-
if route.last == @to_screen
|
|
168
|
-
@route = route
|
|
169
|
-
@depth = nil
|
|
170
|
-
@routes_array = nil
|
|
171
|
-
return
|
|
172
|
-
end
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
tmp_routes_array = Array.new
|
|
176
|
-
@routes_array.each { |route|
|
|
177
|
-
last_direction = route.last
|
|
178
|
-
next unless @screen_map[last_direction]
|
|
179
|
-
@screen_map[last_direction].each { |possible_direction|
|
|
180
|
-
#Skip loops?
|
|
181
|
-
next if route.include?(possible_direction)
|
|
182
|
-
#Skip from screen
|
|
183
|
-
next if possible_direction == @from_screen
|
|
184
|
-
|
|
185
|
-
new_route = route.clone
|
|
186
|
-
new_route.push(possible_direction)
|
|
187
|
-
|
|
188
|
-
unless @routes_array.include?(new_route)
|
|
189
|
-
tmp_routes_array.push(new_route)
|
|
190
|
-
end
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
unless last_direction == @to_screen
|
|
194
|
-
#@routes_array.delete(route)
|
|
195
|
-
end
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
@routes_array += tmp_routes_array
|
|
199
|
-
|
|
200
|
-
@depth += 1
|
|
201
|
-
|
|
202
|
-
if @depth > 100
|
|
203
|
-
ap @routes_array
|
|
204
|
-
raise 'Could not complete route, runaway depth for from screen (' + @from_screen.to_s + ') to screen (' + @to_screen.to_s + ')'
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
self.recursive_route_map
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
def map_screens
|
|
211
|
-
screen_map = Hash.new
|
|
212
|
-
return screen_map unless self.configuration['screens'].class == Hash
|
|
213
|
-
|
|
214
|
-
self.configuration['screens'].each_key { |screen_name|
|
|
215
|
-
screen_class_symbol = self.translate_string_to_class(screen_name)
|
|
216
|
-
|
|
217
|
-
next unless self.respond_to?(screen_class_symbol)
|
|
218
|
-
next unless self.send(screen_class_symbol).configuration.class == Hash
|
|
219
|
-
|
|
220
|
-
screen_map[screen_class_symbol] = Array.new unless screen_map[screen_class_symbol].class == Array
|
|
221
|
-
|
|
222
|
-
screen_configuration = self.send(screen_class_symbol).configuration
|
|
223
|
-
|
|
224
|
-
if screen_configuration['accept'].class == Hash
|
|
225
|
-
possible_change_screen = self.find_possible_change_screen(screen_configuration['accept'])
|
|
226
|
-
screen_map[screen_class_symbol].push(possible_change_screen) if possible_change_screen
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
if screen_configuration.has_key?('dismiss')
|
|
230
|
-
possible_change_screen = self.find_possible_change_screen(screen_configuration['dismiss'])
|
|
231
|
-
screen_map[screen_class_symbol].push(possible_change_screen) if possible_change_screen
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
#Check modals
|
|
235
|
-
if screen_configuration['modals'].is_a?(Hash)
|
|
236
|
-
screen_configuration['modals'].each { |modal_name, modal_configuration|
|
|
237
|
-
next unless modal_configuration.is_a?(Hash)
|
|
238
|
-
next unless modal_configuration['elements'].is_a?(Hash)
|
|
239
|
-
|
|
240
|
-
modal_configuration['elements'].each { |element_name, element_configuration|
|
|
241
|
-
next unless element_configuration.class == Hash
|
|
242
|
-
#next if not element_configuration['click'].class == Hash
|
|
243
|
-
|
|
244
|
-
if @avoid_elements.has_key?(screen_class_symbol)
|
|
245
|
-
next if @avoid_elements[screen_class_symbol].include?(element_name)
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
element_configuration.each { |key, sub_configuration|
|
|
249
|
-
next unless sub_configuration.class == Hash
|
|
250
|
-
next if key == 'custom_methods'
|
|
251
|
-
next if key == 'xpath'
|
|
252
|
-
next if key == 'css'
|
|
253
|
-
next if key == 'multiple'
|
|
254
|
-
|
|
255
|
-
possible_change_screen = self.find_possible_change_screen(sub_configuration)
|
|
256
|
-
screen_map[screen_class_symbol].push(possible_change_screen) if possible_change_screen
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
next unless screen_configuration['elements'].class == Hash
|
|
263
|
-
|
|
264
|
-
screen_configuration['elements'].each { |element_name, element_configuration|
|
|
265
|
-
next unless element_configuration.class == Hash
|
|
266
|
-
#next if not element_configuration['click'].class == Hash
|
|
267
|
-
|
|
268
|
-
if @avoid_elements.has_key?(screen_class_symbol)
|
|
269
|
-
next if @avoid_elements[screen_class_symbol].include?(element_name)
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
element_configuration.each { |key, sub_configuration|
|
|
273
|
-
next unless sub_configuration.class == Hash
|
|
274
|
-
next if key == 'custom_methods'
|
|
275
|
-
next if key == 'xpath'
|
|
276
|
-
next if key == 'css'
|
|
277
|
-
next if key == 'multiple'
|
|
278
|
-
|
|
279
|
-
possible_change_screen = self.find_possible_change_screen(sub_configuration)
|
|
280
|
-
screen_map[screen_class_symbol].push(possible_change_screen) if possible_change_screen
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
screen_map[screen_class_symbol] = screen_map[screen_class_symbol].uniq
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
screen_map
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
def find_possible_change_screen(configuration)
|
|
291
|
-
if configuration['before'].class == Hash
|
|
292
|
-
if configuration['before'].has_key?('change_screen')
|
|
293
|
-
if configuration['before']['change_screen']
|
|
294
|
-
return self.translate_string_to_class(configuration['before']['change_screen'])
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
if configuration['after'].class == Hash
|
|
300
|
-
if configuration['after'].has_key?('change_screen')
|
|
301
|
-
if configuration['after']['change_screen']
|
|
302
|
-
return self.translate_string_to_class(configuration['after']['change_screen'])
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
nil
|
|
308
|
-
end
|
|
309
|
-
end
|
|
310
|
-
end
|