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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class ChangeScreen < ActionLoop
|
|
7
|
+
def initialize(args = {})
|
|
8
|
+
super
|
|
9
|
+
@new_screen_name = args.fetch :blue_prints
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def single_run
|
|
13
|
+
self.driver.document_complete_wait
|
|
14
|
+
|
|
15
|
+
new_screen = self.composite.top.screens[@new_screen_name]
|
|
16
|
+
if new_screen.load.live?
|
|
17
|
+
self.composite.top.set_screen(@new_screen_name)
|
|
18
|
+
return true
|
|
19
|
+
else
|
|
20
|
+
return false
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class ChangeToPreviousScreen < ActionLoop
|
|
7
|
+
def single_run
|
|
8
|
+
self.driver.document_complete_wait
|
|
9
|
+
|
|
10
|
+
new_screen = self.composite.top.current_window.previous_screen_name
|
|
11
|
+
if new_screen.load.live?
|
|
12
|
+
self.composite.top.set_screen(new_screen)
|
|
13
|
+
return true
|
|
14
|
+
else
|
|
15
|
+
return false
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
require_relative '../modal'
|
|
3
|
+
require_relative '../../error'
|
|
4
|
+
|
|
5
|
+
module AutomationObject
|
|
6
|
+
module State
|
|
7
|
+
module BluePrintAdapter
|
|
8
|
+
class CloseModal < ActionLoop
|
|
9
|
+
def single_run
|
|
10
|
+
self.driver.document_complete_wait
|
|
11
|
+
|
|
12
|
+
unless self.composite.parent.is_a?(Modal)
|
|
13
|
+
raise ModalParentExpected.new
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
modal = self.composite.parent
|
|
17
|
+
modal.active = modal.live?
|
|
18
|
+
|
|
19
|
+
if !modal.active?
|
|
20
|
+
self.composite.screen.modal = nil
|
|
21
|
+
self.composite.screen.current_modal = nil
|
|
22
|
+
self.composite.top.destroy_modal()
|
|
23
|
+
return true
|
|
24
|
+
else
|
|
25
|
+
return false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
require_relative '../../error'
|
|
3
|
+
|
|
4
|
+
module AutomationObject
|
|
5
|
+
module State
|
|
6
|
+
module BluePrintAdapter
|
|
7
|
+
class CloseScreen < ActionLoop
|
|
8
|
+
def single_run
|
|
9
|
+
unless self.composite.screen
|
|
10
|
+
raise ScreenParentExpected.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
screen_name = self.composite.screen.name
|
|
14
|
+
return self.composite.top.window_closed?(screen_name)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class ElementRequirement < ActionLoop
|
|
7
|
+
def element
|
|
8
|
+
@element ||= self.driver.find_element(*self.blue_prints.element_blueprints.selector_params)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def single_run
|
|
12
|
+
self.blue_prints.hook_order.each { |requirement_name|
|
|
13
|
+
next if self.blue_prints.requirement(requirement_name) == nil
|
|
14
|
+
|
|
15
|
+
requirement_value = self.blue_prints.requirement(requirement_name)
|
|
16
|
+
|
|
17
|
+
case requirement_name
|
|
18
|
+
when :exists?
|
|
19
|
+
if requirement_value != self.driver.exists?(*self.blue_prints.element_blueprints.selector_params)
|
|
20
|
+
return false
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
if requirement_value != self.element.send(requirement_name)
|
|
24
|
+
return false
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return true
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
require_relative '../../error'
|
|
3
|
+
|
|
4
|
+
module AutomationObject
|
|
5
|
+
module State
|
|
6
|
+
module BluePrintAdapter
|
|
7
|
+
class NewScreen < ActionLoop
|
|
8
|
+
def initialize(args = {})
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def single_run
|
|
13
|
+
new_screen_name = self.blue_prints
|
|
14
|
+
new_screen = self.composite.top.screens[new_screen_name]
|
|
15
|
+
|
|
16
|
+
stored_window_handles = self.composite.top.window_handles
|
|
17
|
+
driver_handles = self.driver.window_handles
|
|
18
|
+
|
|
19
|
+
if driver_handles.length <= stored_window_handles.length
|
|
20
|
+
return false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if (driver_handles.length - stored_window_handles.length) > 1
|
|
24
|
+
raise MoreThenOneScreenCreated.new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
self.composite.top.create_screen(new_screen_name)
|
|
28
|
+
self.composite.top.use_screen(new_screen_name)
|
|
29
|
+
|
|
30
|
+
self.driver.document_complete_wait
|
|
31
|
+
|
|
32
|
+
return new_screen.load.live?
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class PossibleScreenChanges < ActionLoop
|
|
7
|
+
def single_run
|
|
8
|
+
self.blue_prints.each { |possible_screen_name|
|
|
9
|
+
new_screen = self.composite.top.screens[possible_screen_name]
|
|
10
|
+
if possible_screen_name.load.live?
|
|
11
|
+
self.composite.top.set_screen(possible_screen_name)
|
|
12
|
+
return true
|
|
13
|
+
end
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return false
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class ResetScreen < ActionLoop
|
|
7
|
+
def single_run
|
|
8
|
+
unless self.composite.screen
|
|
9
|
+
raise ScreenParentExpected.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
screen_name = self.composite.screen.name
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class ShowModal < ActionLoop
|
|
7
|
+
def initialize(args = {})
|
|
8
|
+
super
|
|
9
|
+
@new_modal_name = args.fetch :blue_prints
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def single_run
|
|
13
|
+
new_modal = self.composite.screen.modals[@new_modal_name]
|
|
14
|
+
|
|
15
|
+
if new_modal.load.live? != false
|
|
16
|
+
self.composite.screen.current_modal = @new_modal_name
|
|
17
|
+
self.composite.screen.modal = new_modal
|
|
18
|
+
return true
|
|
19
|
+
else
|
|
20
|
+
return false
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class Sleep < ActionLoop
|
|
7
|
+
def initialize(args = {})
|
|
8
|
+
super
|
|
9
|
+
@time = args.fetch :blue_prints
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def single_run
|
|
13
|
+
sleep(@time)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative 'action_loop'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
module BluePrintAdapter
|
|
6
|
+
class WaitForElements < ActionLoop
|
|
7
|
+
def single_run
|
|
8
|
+
self.blue_prints.each { |hook_element_requirement|
|
|
9
|
+
hook_element_requirement = ElementRequirement.new(blue_prints: hook_element_requirement,
|
|
10
|
+
composite: self,
|
|
11
|
+
loops: 1)
|
|
12
|
+
return false unless hook_element_requirement.run
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return true
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative 'composite'
|
|
2
|
+
|
|
3
|
+
require_relative 'element'
|
|
4
|
+
require_relative 'element_array'
|
|
5
|
+
require_relative 'element_hash'
|
|
6
|
+
|
|
7
|
+
module AutomationObject
|
|
8
|
+
module State
|
|
9
|
+
module BluePrintAdapter
|
|
10
|
+
#TODO: refactor to container
|
|
11
|
+
class Modal < AutomationObject::State::BluePrintAdapter::Composite
|
|
12
|
+
has_one :load, interface: Hook
|
|
13
|
+
|
|
14
|
+
has_many :elements, interface: Element
|
|
15
|
+
has_many :element_arrays, interface: ElementArray
|
|
16
|
+
has_many :element_hashes, interface: ElementHash
|
|
17
|
+
|
|
18
|
+
attr_accessor :active
|
|
19
|
+
# @return [Boolean] screen is active or not
|
|
20
|
+
def active
|
|
21
|
+
return @active ||= false
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require_relative 'composite'
|
|
2
|
+
|
|
3
|
+
require_relative 'modal'
|
|
4
|
+
require_relative 'hook'
|
|
5
|
+
require_relative 'element'
|
|
6
|
+
require_relative 'element_array'
|
|
7
|
+
require_relative 'element_hash'
|
|
8
|
+
|
|
9
|
+
module AutomationObject
|
|
10
|
+
module State
|
|
11
|
+
module BluePrintAdapter
|
|
12
|
+
class Screen < AutomationObject::State::BluePrintAdapter::Composite
|
|
13
|
+
attr_accessor :modal, :current_modal
|
|
14
|
+
|
|
15
|
+
has_one :load, interface: Hook
|
|
16
|
+
|
|
17
|
+
#Children for this composite
|
|
18
|
+
has_many :modals, interface: Modal
|
|
19
|
+
|
|
20
|
+
has_many :elements, interface: Element
|
|
21
|
+
has_many :element_arrays, interface: ElementArray
|
|
22
|
+
has_many :element_hashes, interface: ElementHash
|
|
23
|
+
|
|
24
|
+
attr_accessor :active
|
|
25
|
+
# @return [Boolean] screen is active or not
|
|
26
|
+
def active
|
|
27
|
+
return @active ||= false
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative 'composite'
|
|
2
|
+
require_relative 'screen'
|
|
3
|
+
|
|
4
|
+
require_relative 'helpers/screen_manager'
|
|
5
|
+
|
|
6
|
+
require_relative '../error'
|
|
7
|
+
|
|
8
|
+
module AutomationObject
|
|
9
|
+
module State
|
|
10
|
+
module BluePrintAdapter
|
|
11
|
+
class Top < AutomationObject::State::BluePrintAdapter::Composite
|
|
12
|
+
include ScreenManager
|
|
13
|
+
|
|
14
|
+
#Children for this composite
|
|
15
|
+
has_many :screens, interface: Screen
|
|
16
|
+
|
|
17
|
+
# @return [Symbol] symbol of the initial screen found
|
|
18
|
+
def create
|
|
19
|
+
self.driver.get(self.blue_prints.base_url) if self.blue_prints.base_url
|
|
20
|
+
self.set_screen(self.initial_screen)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def initial_screen
|
|
24
|
+
#If default screen then check if its live and set it
|
|
25
|
+
if self.blue_prints.default_screen
|
|
26
|
+
screen_name = self.blue_prints.default_screen
|
|
27
|
+
default_screen_live = self.screens[screen_name].load.live?
|
|
28
|
+
|
|
29
|
+
if default_screen_live == nil or default_screen_live == true
|
|
30
|
+
return screen_name
|
|
31
|
+
else
|
|
32
|
+
raise AutomationObject::State::NoInitialScreenError.new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
self.screens.each { |screen_name, screen|
|
|
37
|
+
return screen_name if screen.load.live?
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
raise AutomationObject::State::NoInitialScreenError.new
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module AutomationObject
|
|
2
|
+
module State
|
|
3
|
+
class UndefinedLoadTypeError < StandardError;
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class NoInitialScreenError < StandardError
|
|
7
|
+
def initialize(message = 'No initial screen to be set to')
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class ScreenNotActiveError < StandardError
|
|
13
|
+
def initialize(screen)
|
|
14
|
+
message = "#{screen} is not currently active"
|
|
15
|
+
super(message)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class ModalNotActiveError < StandardError; end
|
|
20
|
+
class ModalParentExpected < StandardError; end
|
|
21
|
+
class ScreenParentExpected < StandardError; end
|
|
22
|
+
class MoreThenOneScreenCreated < StandardError; end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require_relative 'error'
|
|
2
|
+
|
|
3
|
+
module AutomationObject
|
|
4
|
+
module State
|
|
5
|
+
#Store session details, methods for controlling viewing current driver session.
|
|
6
|
+
class Session
|
|
7
|
+
attr_accessor :driver, :composite
|
|
8
|
+
|
|
9
|
+
def initialize(args={})
|
|
10
|
+
self.driver = args.fetch :driver
|
|
11
|
+
self.composite = args.fetch :composite
|
|
12
|
+
|
|
13
|
+
self.composite.create
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def load(type, name)
|
|
17
|
+
case type
|
|
18
|
+
when :screen
|
|
19
|
+
unless self.composite.screen_exists?(name)
|
|
20
|
+
raise AutomationObject::State::ScreenNotActiveError.new(name)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
self.composite.use_screen(name)
|
|
24
|
+
when :modal
|
|
25
|
+
unless self.composite.screens[self.composite.current_screen].current_modal == name
|
|
26
|
+
raise AutomationObject::State::ModalNotActiveError.new(name)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
self.composite.use_modal(name)
|
|
30
|
+
when :element, :element_array, :element_hash
|
|
31
|
+
return self.composite.get_object(type, name)
|
|
32
|
+
else
|
|
33
|
+
raise AutomationObject::State::UndefinedLoadTypeError.new
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|