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
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'composite'
|
2
|
+
require_relative 'helpers/element_helper'
|
3
|
+
|
4
|
+
require_relative 'element_proxy'
|
5
|
+
|
6
|
+
module AutomationObject
|
7
|
+
module State
|
8
|
+
module BluePrintAdapter
|
9
|
+
class Element < AutomationObject::State::BluePrintAdapter::Composite
|
10
|
+
include ElementHelper
|
11
|
+
|
12
|
+
# @return [AutomationObject::State::BluePrintAdapter::ElementProxy] Selenium proxy
|
13
|
+
def load
|
14
|
+
element = self.driver.find_element(*self.blue_prints.selector_params)
|
15
|
+
ElementProxy.new(composite: self, element: element)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'composite'
|
2
|
+
require_relative 'helpers/element_helper'
|
3
|
+
|
4
|
+
require_relative 'element_proxy'
|
5
|
+
|
6
|
+
module AutomationObject
|
7
|
+
module State
|
8
|
+
module BluePrintAdapter
|
9
|
+
class ElementArray < AutomationObject::State::BluePrintAdapter::Composite
|
10
|
+
include ElementHelper
|
11
|
+
|
12
|
+
# @return [Array<AutomationObject::State::BluePrintAdapter::ElementProxy>] Selenium proxy
|
13
|
+
def load
|
14
|
+
elements = self.driver.find_elements(*self.blue_prints.selector_params)
|
15
|
+
|
16
|
+
wrapped_elements = elements.map { |element|
|
17
|
+
ElementProxy.new(composite: self, element: element)
|
18
|
+
}
|
19
|
+
|
20
|
+
return wrapped_elements
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'composite'
|
2
|
+
require_relative 'helpers/element_helper'
|
3
|
+
|
4
|
+
require_relative 'element_proxy'
|
5
|
+
|
6
|
+
module AutomationObject
|
7
|
+
module State
|
8
|
+
module BluePrintAdapter
|
9
|
+
class ElementHash < AutomationObject::State::BluePrintAdapter::Composite
|
10
|
+
include ElementHelper
|
11
|
+
|
12
|
+
# @return [Hash<String, AutomationObject::State::BluePrintAdapter::ElementProxy>] Selenium proxy
|
13
|
+
def load
|
14
|
+
elements = self.driver.find_elements(*self.blue_prints.selector_params)
|
15
|
+
elements_hash = {}
|
16
|
+
|
17
|
+
elements.each { |element|
|
18
|
+
#Want to wrap element, before sending for method!
|
19
|
+
#That will help us include custom methods, etc...
|
20
|
+
wrapped_element = ElementProxy.new(composite: self, element: element)
|
21
|
+
hash_key = wrapped_element.send(self.blue_prints.define_elements_by) #Send to wrapped state proxy
|
22
|
+
|
23
|
+
elements_hash[hash_key] = wrapped_element
|
24
|
+
}
|
25
|
+
|
26
|
+
return elements_hash
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../../proxies/proxy'
|
2
|
+
|
3
|
+
module AutomationObject
|
4
|
+
module State
|
5
|
+
module BluePrintAdapter
|
6
|
+
#Proxy class to allow for usage of hooks
|
7
|
+
class ElementProxy < AutomationObject::Proxies::Proxy
|
8
|
+
def initialize(args = {})
|
9
|
+
@composite = args.fetch :composite
|
10
|
+
@subject = args.fetch :element
|
11
|
+
end
|
12
|
+
|
13
|
+
#Overiding base method to run possible hooks
|
14
|
+
def method_missing(method_symbol, *args, &block)
|
15
|
+
#Run before hook if needed
|
16
|
+
@composite.method_hooks[method_symbol].before if @composite.method_hook?(method_symbol)
|
17
|
+
|
18
|
+
subject_return = @subject.send(method_symbol, *args, &block)
|
19
|
+
|
20
|
+
#Run after hook if needed
|
21
|
+
@composite.method_hooks[method_symbol].after if @composite.method_hook?(method_symbol)
|
22
|
+
|
23
|
+
return subject_return
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../hook'
|
2
|
+
|
3
|
+
module AutomationObject
|
4
|
+
module State
|
5
|
+
#Helper module for Element composite classes
|
6
|
+
module BluePrintAdapter
|
7
|
+
module ElementHelper
|
8
|
+
def method_hook?(name)
|
9
|
+
return self.blue_prints.method_hooks.has_key?(name)
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Hash<Hook>] array of Hook that are defined under the element
|
13
|
+
def method_hooks
|
14
|
+
return @method_hooks if @method_hooks
|
15
|
+
|
16
|
+
@method_hooks = {}
|
17
|
+
self.blue_prints.method_hooks.each { |key, blue_prints|
|
18
|
+
@method_hooks[key] = Hook.new(blue_prints,
|
19
|
+
self.driver,
|
20
|
+
key,
|
21
|
+
self,
|
22
|
+
self.location + "[#{key}]")
|
23
|
+
}
|
24
|
+
|
25
|
+
return @method_hooks
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require_relative 'window'
|
2
|
+
|
3
|
+
module AutomationObject
|
4
|
+
module State
|
5
|
+
module BluePrintAdapter
|
6
|
+
module ScreenManager
|
7
|
+
# @return [Array<Window>]
|
8
|
+
def windows
|
9
|
+
@windows ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Array<String>] list of stored window handles
|
13
|
+
def window_handles
|
14
|
+
handles = []
|
15
|
+
self.windows.each { |window|
|
16
|
+
handles.push(window.window_handle)
|
17
|
+
}
|
18
|
+
return handles
|
19
|
+
end
|
20
|
+
|
21
|
+
def window_closed?(screen)
|
22
|
+
self.windows.each { |window|
|
23
|
+
if window.name == screen && window.closed?
|
24
|
+
self.delete_screen(screen)
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_screen(name)
|
31
|
+
current_window_handle = self.driver.window_handle
|
32
|
+
previous_window = nil
|
33
|
+
|
34
|
+
self.windows.each { |window|
|
35
|
+
if window.window_handle == current_window_handle
|
36
|
+
previous_window = self.windows.delete(window)
|
37
|
+
break
|
38
|
+
end
|
39
|
+
}
|
40
|
+
|
41
|
+
self.windows << Window.new(name: name,
|
42
|
+
window_handle: current_window_handle,
|
43
|
+
previous_window: previous_window,
|
44
|
+
driver: self.driver)
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_screen(name)
|
48
|
+
driver_handles = self.driver.window_handles
|
49
|
+
diff_handles = driver_handles - self.window_handles
|
50
|
+
|
51
|
+
#Should only have one extra window
|
52
|
+
if diff_handles.length > 1
|
53
|
+
raise "Expecting only one extra window, got #{diff_handles.length}"
|
54
|
+
end
|
55
|
+
|
56
|
+
self.windows << Window.new(name: name, window_handle: diff_handles.first, driver: self.driver)
|
57
|
+
end
|
58
|
+
|
59
|
+
def use_screen(name)
|
60
|
+
current_window_handle = self.driver.window_handle
|
61
|
+
self.windows.each { |window|
|
62
|
+
next unless window.name == name
|
63
|
+
|
64
|
+
break if window.window_handle == current_window_handle
|
65
|
+
|
66
|
+
self.driver.window_handle = window.window_handle
|
67
|
+
}
|
68
|
+
|
69
|
+
@current_screen_name = name
|
70
|
+
end
|
71
|
+
|
72
|
+
def use_modal(modal_name)
|
73
|
+
current_window.active_modal = modal_name
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete_screen(name)
|
77
|
+
self.windows.each { |window|
|
78
|
+
self.windows.delete(name) if window.name == name
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def screen_exists?(name)
|
83
|
+
self.windows.each { |window|
|
84
|
+
return true if window.name == name
|
85
|
+
}
|
86
|
+
|
87
|
+
return false
|
88
|
+
end
|
89
|
+
|
90
|
+
def destroy_modal
|
91
|
+
current_window.active_modal = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
# @return [Window, nil]
|
95
|
+
def current_window
|
96
|
+
return nil unless @current_screen_name
|
97
|
+
return self.get_window(@current_screen_name)
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_window(name)
|
101
|
+
self.windows.each { |window|
|
102
|
+
return window if name == window.name
|
103
|
+
}
|
104
|
+
|
105
|
+
return nil
|
106
|
+
end
|
107
|
+
|
108
|
+
def current_composite
|
109
|
+
if current_window.active_modal
|
110
|
+
return self.screens[@current_screen_name].modals[current_window.active_modal]
|
111
|
+
end
|
112
|
+
|
113
|
+
return self.screens[@current_screen_name]
|
114
|
+
end
|
115
|
+
|
116
|
+
def current_screen
|
117
|
+
@current_screen_name
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_object(type, name)
|
121
|
+
object = nil
|
122
|
+
|
123
|
+
case type
|
124
|
+
when :element
|
125
|
+
object = self.current_composite.elements[name]
|
126
|
+
when :element_array
|
127
|
+
object = self.current_composite.element_arrays[name]
|
128
|
+
when :element_hash
|
129
|
+
object = self.current_composite.element_hashes[name]
|
130
|
+
end
|
131
|
+
|
132
|
+
return object.load
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module AutomationObject
|
2
|
+
module State
|
3
|
+
module BluePrintAdapter
|
4
|
+
class Window
|
5
|
+
attr_accessor :name, :window_handle, :previous_window, :driver, :active_modal
|
6
|
+
|
7
|
+
def initialize(args = {})
|
8
|
+
self.name = args.fetch :name
|
9
|
+
self.driver = args.fetch :driver
|
10
|
+
self.window_handle = args.fetch :window_handle
|
11
|
+
|
12
|
+
self.previous_window = args.fetch :previous_window, nil
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Symbol, nil] name of screen or nil
|
16
|
+
def previous_screen_name
|
17
|
+
return (self.previous_window) ? self.previous_window.name : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
#Change properties to the previous window if it exists
|
21
|
+
def back
|
22
|
+
return unless self.previous_window
|
23
|
+
|
24
|
+
self.name = self.previous_window.name
|
25
|
+
|
26
|
+
if self.previous_window.previous_window
|
27
|
+
self.previous_window = self.previous_window.previous_window
|
28
|
+
else
|
29
|
+
self.previous_window = nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def closed?
|
34
|
+
return !self.driver.window_handles.include?(self.window_handle)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative 'composite'
|
2
|
+
|
3
|
+
require_relative 'hook_action'
|
4
|
+
require_relative 'hook_actions/element_requirement'
|
5
|
+
|
6
|
+
module AutomationObject
|
7
|
+
module State
|
8
|
+
module BluePrintAdapter
|
9
|
+
class Hook < AutomationObject::State::BluePrintAdapter::Composite
|
10
|
+
# @return [Boolean, nil] return nil if no live? check, otherwise boolean
|
11
|
+
def live?
|
12
|
+
self.before
|
13
|
+
|
14
|
+
return nil if self.blue_prints.live?.empty?
|
15
|
+
|
16
|
+
self.blue_prints.live?.each { |element_requirement_blueprints|
|
17
|
+
hook_element_requirement = ElementRequirement.new(blue_prints: element_requirement_blueprints,
|
18
|
+
composite: self,
|
19
|
+
loops: 1)
|
20
|
+
return false unless hook_element_requirement.run
|
21
|
+
}
|
22
|
+
|
23
|
+
self.after
|
24
|
+
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
|
28
|
+
#Runs the before hook
|
29
|
+
# @return [Boolean, nil] return nil unless there is a hook, otherwise boolean depending on success of hook
|
30
|
+
def before
|
31
|
+
return nil if self.blue_prints.before.empty?
|
32
|
+
|
33
|
+
hook_action = HookAction.new(self.blue_prints.before,
|
34
|
+
self.driver,
|
35
|
+
:hook_action,
|
36
|
+
self,
|
37
|
+
self.location + '[hook_action]')
|
38
|
+
return hook_action.run
|
39
|
+
end
|
40
|
+
|
41
|
+
#Runs the after hook
|
42
|
+
# @return [Boolean, nil] return nil unless there is a hook, otherwise boolean depending on success of hook
|
43
|
+
def after
|
44
|
+
return nil if self.blue_prints.after.empty?
|
45
|
+
|
46
|
+
hook_action = HookAction.new(self.blue_prints.after,
|
47
|
+
self.driver,
|
48
|
+
:hook_action,
|
49
|
+
self,
|
50
|
+
self.location + '[hook_action]')
|
51
|
+
return hook_action.run
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'composite'
|
2
|
+
|
3
|
+
require_relative 'hook_actions/change_screen'
|
4
|
+
require_relative 'hook_actions/change_to_previous_screen'
|
5
|
+
require_relative 'hook_actions/close_modal'
|
6
|
+
require_relative 'hook_actions/close_screen'
|
7
|
+
require_relative 'hook_actions/possible_screen_changes'
|
8
|
+
require_relative 'hook_actions/reset_screen'
|
9
|
+
require_relative 'hook_actions/show_modal'
|
10
|
+
require_relative 'hook_actions/sleep'
|
11
|
+
require_relative 'hook_actions/wait_for_elements'
|
12
|
+
require_relative 'hook_actions/new_screen'
|
13
|
+
|
14
|
+
module AutomationObject
|
15
|
+
module State
|
16
|
+
module BluePrintAdapter
|
17
|
+
class HookAction < AutomationObject::State::BluePrintAdapter::Composite
|
18
|
+
# @return [Boolean] run success or not
|
19
|
+
def run
|
20
|
+
self.blue_prints.hook_order.each { |hook_name|
|
21
|
+
hook_action_class = AutomationObject::State::BluePrintAdapter.const_get(hook_name.to_s.pascalize)
|
22
|
+
blue_prints = self.blue_prints.send(hook_name)
|
23
|
+
|
24
|
+
hook_action = hook_action_class.new(blue_prints: blue_prints, composite: self)
|
25
|
+
return false if hook_action.run == false
|
26
|
+
}
|
27
|
+
|
28
|
+
return true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module AutomationObject
|
2
|
+
module State
|
3
|
+
module BluePrintAdapter
|
4
|
+
class ActionLoop
|
5
|
+
attr_accessor :composite, :blue_prints, :loops
|
6
|
+
|
7
|
+
def initialize(args = {})
|
8
|
+
self.blue_prints = args.fetch(:blue_prints)
|
9
|
+
self.composite = args.fetch(:composite)
|
10
|
+
self.loops = args.fetch(:loops, 30)
|
11
|
+
end
|
12
|
+
|
13
|
+
def driver
|
14
|
+
return self.composite.driver
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Boolean] run success or not
|
18
|
+
def run
|
19
|
+
self.loops.times do
|
20
|
+
if self.single_run
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Boolean] success or not
|
29
|
+
def single_run
|
30
|
+
raise 'Abstract Issue'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|