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,52 @@
|
|
|
1
|
+
#Require parent class
|
|
2
|
+
require_relative 'composite'
|
|
3
|
+
|
|
4
|
+
#Require child classes
|
|
5
|
+
require_relative 'element'
|
|
6
|
+
require_relative 'element_array'
|
|
7
|
+
require_relative 'element_hash'
|
|
8
|
+
require_relative 'hook'
|
|
9
|
+
|
|
10
|
+
module AutomationObject
|
|
11
|
+
module BluePrint
|
|
12
|
+
module HashAdapter
|
|
13
|
+
#Modal-level composite, ActiveRecord style composite implementation inheriting from Composite
|
|
14
|
+
class Modal < Composite
|
|
15
|
+
#Relationships
|
|
16
|
+
has_one :load, interface: Hook
|
|
17
|
+
|
|
18
|
+
has_many :elements, interface: Element
|
|
19
|
+
has_many :element_arrays, interface: ElementArray
|
|
20
|
+
has_many :element_hashes, interface: ElementHash
|
|
21
|
+
|
|
22
|
+
#Validations
|
|
23
|
+
validates_keys allowed_keys: [:load, :elements, :element_arrays, :element_hashes]
|
|
24
|
+
|
|
25
|
+
validates :load, instance_of: Hash
|
|
26
|
+
validates :elements, instance_of: Hash
|
|
27
|
+
validates :element_arrays, instance_of: Hash
|
|
28
|
+
validates :element_hashes, instance_of: Hash
|
|
29
|
+
|
|
30
|
+
# @return [Array<Symbol>] array of views this can has
|
|
31
|
+
def included_views
|
|
32
|
+
included_views_array = self.hash[:included_views] ||= Array.new
|
|
33
|
+
included_views_array.map { |view| view.to_sym }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#Method to take views and merge into this composite
|
|
37
|
+
def merge_views
|
|
38
|
+
top_hash = self.top.hash
|
|
39
|
+
|
|
40
|
+
return unless top_hash.is_a?(Hash)
|
|
41
|
+
return unless top_hash[:views].is_a?(Hash)
|
|
42
|
+
top_view_hash = top_hash[:views]
|
|
43
|
+
|
|
44
|
+
self.included_views.each { |included_view|
|
|
45
|
+
next unless top_view_hash[included_view].is_a?(Hash)
|
|
46
|
+
self.hash = self.hash.deep_merge(top_view_hash[included_view])
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#Require parent class
|
|
2
|
+
require_relative 'composite'
|
|
3
|
+
|
|
4
|
+
#Require child classes
|
|
5
|
+
require_relative 'automatic_onload_modal'
|
|
6
|
+
require_relative 'element'
|
|
7
|
+
require_relative 'element_array'
|
|
8
|
+
require_relative 'element_hash'
|
|
9
|
+
require_relative 'hook'
|
|
10
|
+
require_relative 'modal'
|
|
11
|
+
|
|
12
|
+
module AutomationObject
|
|
13
|
+
module BluePrint
|
|
14
|
+
module HashAdapter
|
|
15
|
+
#Screen-level composite, ActiveRecord style composite implementation inheriting from Composite
|
|
16
|
+
class Screen < Composite
|
|
17
|
+
#Creation hooks
|
|
18
|
+
before_create :merge_views
|
|
19
|
+
before_create :automatic_onload_modals
|
|
20
|
+
|
|
21
|
+
#Relationships
|
|
22
|
+
has_one :load, interface: Hook
|
|
23
|
+
has_one :accept, interface: Hook
|
|
24
|
+
has_one :dismiss, interface: Hook
|
|
25
|
+
|
|
26
|
+
has_many :modals, interface: Modal
|
|
27
|
+
has_many :elements, interface: Element
|
|
28
|
+
has_many :element_arrays, interface: ElementArray
|
|
29
|
+
has_many :element_hashes, interface: ElementHash
|
|
30
|
+
|
|
31
|
+
#Validations
|
|
32
|
+
validates_keys allowed_keys: [:automatic_onload_modals, :automatic_screen_changes, :elements,
|
|
33
|
+
:element_arrays, :element_hashes, :included_views, :load, :modals]
|
|
34
|
+
|
|
35
|
+
validates :automatic_onload_modals, instance_of: Array, modal_presence_of: true
|
|
36
|
+
validates :automatic_screen_changes, instance_of: Array, screen_presence_of: true
|
|
37
|
+
|
|
38
|
+
validates :elements, instance_of: Hash
|
|
39
|
+
validates :element_arrays, instance_of: Hash
|
|
40
|
+
validates :element_hashes, instance_of: Hash
|
|
41
|
+
|
|
42
|
+
validates :included_views, instance_of: Array, view_presence_of: true
|
|
43
|
+
|
|
44
|
+
validates :load, instance_of: Hash
|
|
45
|
+
validates :accept, instance_of: Hash
|
|
46
|
+
validates :dismiss, instance_of: Hash
|
|
47
|
+
|
|
48
|
+
validates :modals, instance_of: Hash
|
|
49
|
+
|
|
50
|
+
# @return [Array<AutomaticOnloadModal>] array of AutomaticOnloadModal that are defined under the screen
|
|
51
|
+
def automatic_onload_modals
|
|
52
|
+
return @automatic_onload_modals if @automatic_onload_modals
|
|
53
|
+
|
|
54
|
+
children = self.hash[:automatic_onload_modals]
|
|
55
|
+
children = (children.is_a?(Array)) ? children : Array.new
|
|
56
|
+
@automatic_onload_modals = self.create_array_children(:automatic_onload_modals, children,
|
|
57
|
+
{interface: AutomaticOnloadModal,
|
|
58
|
+
location: self.location + '[automatic_onload_modals]'})
|
|
59
|
+
|
|
60
|
+
return @automatic_onload_modals
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @return [Array<Symbol>] array of screens where screen can automatically change to
|
|
64
|
+
def automatic_screen_changes
|
|
65
|
+
screen_array = self.hash[:automatic_screen_changes] ||= Array.new
|
|
66
|
+
screen_array.map { |screen| screen.to_sym }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @return [Array<Symbol>] array of views this can has
|
|
70
|
+
def included_views
|
|
71
|
+
included_views_array = self.hash[:included_views] ||= Array.new
|
|
72
|
+
included_views_array.map { |view| view.to_sym }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#Method to take views and merge into this composite
|
|
76
|
+
def merge_views
|
|
77
|
+
top_hash = self.top.hash
|
|
78
|
+
|
|
79
|
+
return unless top_hash.is_a?(Hash)
|
|
80
|
+
return unless top_hash[:views].is_a?(Hash)
|
|
81
|
+
top_view_hash = top_hash[:views]
|
|
82
|
+
|
|
83
|
+
self.included_views.each { |included_view|
|
|
84
|
+
next unless top_view_hash[included_view].is_a?(Hash)
|
|
85
|
+
self.hash = self.hash.deep_merge(top_view_hash[included_view])
|
|
86
|
+
}
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#Require parent class
|
|
2
|
+
require_relative 'composite'
|
|
3
|
+
|
|
4
|
+
#Require child classes
|
|
5
|
+
require_relative 'screen'
|
|
6
|
+
require_relative 'view'
|
|
7
|
+
|
|
8
|
+
module AutomationObject
|
|
9
|
+
module BluePrint
|
|
10
|
+
module HashAdapter
|
|
11
|
+
#Top composite
|
|
12
|
+
class Top < Composite
|
|
13
|
+
#Relationships
|
|
14
|
+
has_many :screens, interface: Screen
|
|
15
|
+
has_many :views, interface: View
|
|
16
|
+
|
|
17
|
+
#Validations
|
|
18
|
+
validates_keys allowed_keys: [:base_url, :default_screen, :screen_transition_sleep, :screens,
|
|
19
|
+
:throttle_driver_methods, :throttle_element_methods, :views]
|
|
20
|
+
|
|
21
|
+
validates :base_url, instance_of: String
|
|
22
|
+
validates :default_screen, instance_of: [Symbol, String], screen_presence_of: true
|
|
23
|
+
validates :screen_transition_sleep, instance_of: Numeric
|
|
24
|
+
validates :screens, instance_of: Hash
|
|
25
|
+
validates :throttle_driver_methods, instance_of: Hash
|
|
26
|
+
validates :throttle_element_methods, instance_of: Hash
|
|
27
|
+
validates :views, instance_of: Hash
|
|
28
|
+
|
|
29
|
+
# @return [String, nil] base url to navigate to upon framework creation
|
|
30
|
+
def base_url
|
|
31
|
+
self.hash[:base_url] ||= nil
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @return [Symbol, nil] default screen to be set when framework is created
|
|
35
|
+
def default_screen
|
|
36
|
+
default_screen = self.hash[:default_screen]
|
|
37
|
+
|
|
38
|
+
case default_screen
|
|
39
|
+
when Symbol, String
|
|
40
|
+
return default_screen.to_sym
|
|
41
|
+
else
|
|
42
|
+
return nil
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [Numeric] sleep when transitioning screens
|
|
47
|
+
def screen_transition_sleep
|
|
48
|
+
self.hash[:screen_transition_sleep] ||= 0
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @return [Hash] driver methods to throttle
|
|
52
|
+
def throttle_driver_methods
|
|
53
|
+
self.hash[:throttle_driver_methods] ||= Hash.new
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @return [Hash] element methods to throttle
|
|
57
|
+
def throttle_element_methods
|
|
58
|
+
self.hash[:throttle_element_methods] ||= Hash.new
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#Require parent class
|
|
2
|
+
require_relative 'composite'
|
|
3
|
+
|
|
4
|
+
module AutomationObject
|
|
5
|
+
module BluePrint
|
|
6
|
+
module HashAdapter
|
|
7
|
+
#View composite
|
|
8
|
+
class View < Composite
|
|
9
|
+
#Validations
|
|
10
|
+
validates_keys allowed_keys: [:automatic_onload_modals, :automatic_screen_changes, :elements, :element_arrays,
|
|
11
|
+
:element_groups, :element_hashes, :included_views, :load, :modals]
|
|
12
|
+
|
|
13
|
+
validates :automatic_onload_modals, instance_of: Array, modal_presence_of: true
|
|
14
|
+
validates :automatic_screen_changes, instance_of: Array, screen_presence_of: true
|
|
15
|
+
|
|
16
|
+
validates :elements, instance_of: Hash
|
|
17
|
+
validates :element_arrays, instance_of: Hash
|
|
18
|
+
validates :element_groups, instance_of: Hash
|
|
19
|
+
validates :element_hashes, instance_of: Hash
|
|
20
|
+
|
|
21
|
+
validates :included_views, instance_of: Array, view_presence_of: true
|
|
22
|
+
|
|
23
|
+
validates :load, instance_of: Hash
|
|
24
|
+
|
|
25
|
+
validates :modals, instance_of: Hash
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module AutomationObject::BluePrint
|
|
2
|
+
#Collect files in directory recursively and return Array
|
|
3
|
+
module FileHelper
|
|
4
|
+
# @param path [String] specified directory path for getting files underneath
|
|
5
|
+
# @returns [Array] list of file paths that exist recursively underneath a directory
|
|
6
|
+
def collect_files(path)
|
|
7
|
+
unless File.exists?(path)
|
|
8
|
+
raise "Expecting path to exist, got #{path}"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
if File.directory?(path)
|
|
12
|
+
@file_array = Array.new
|
|
13
|
+
self.recursive_collection(path)
|
|
14
|
+
else
|
|
15
|
+
@file_array = [path]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
@file_array
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
protected
|
|
22
|
+
|
|
23
|
+
# Use for recursive collection of files
|
|
24
|
+
# @param path [String] specified directory path for getting files underneath
|
|
25
|
+
def recursive_collection(path)
|
|
26
|
+
Dir.foreach(path) do |item|
|
|
27
|
+
next if item == '.' or item == '..'
|
|
28
|
+
|
|
29
|
+
file_path = File.join(path, "#{item}")
|
|
30
|
+
if File.directory?(file_path)
|
|
31
|
+
self.recursive_collection(file_path)
|
|
32
|
+
else
|
|
33
|
+
@file_array.push(file_path)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
require_relative '../blue_print'
|
|
4
|
+
require_relative 'hash_adapter'
|
|
5
|
+
require_relative 'helpers/file_helper'
|
|
6
|
+
|
|
7
|
+
module AutomationObject::BluePrint
|
|
8
|
+
#BluePrint YAML Adapter
|
|
9
|
+
module YamlAdapter
|
|
10
|
+
extend self
|
|
11
|
+
extend FileHelper
|
|
12
|
+
|
|
13
|
+
# @param path [String] path to YAML directory
|
|
14
|
+
# @return [AutomationObject::BluePrint::Composite::Top] Composite BluePrint Object
|
|
15
|
+
def build(path = '')
|
|
16
|
+
path = File.expand_path(path)
|
|
17
|
+
|
|
18
|
+
file_array = self.collect_files(path)
|
|
19
|
+
merged_yaml_hash = self.load_yaml_files(file_array)
|
|
20
|
+
|
|
21
|
+
return AutomationObject::BluePrint::HashAdapter.build(merged_yaml_hash)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @param file_array [Array<String>] array of file paths to load
|
|
25
|
+
# @return [Hash] merged YAML Hash
|
|
26
|
+
def load_yaml_files(file_array)
|
|
27
|
+
merged_yaml_hash = Hash.new
|
|
28
|
+
|
|
29
|
+
file_array.each { |file_path|
|
|
30
|
+
next unless self.is_yaml_file?(file_path)
|
|
31
|
+
|
|
32
|
+
file_hash = YAML.load_file(file_path)
|
|
33
|
+
|
|
34
|
+
unless file_hash.is_a?(Hash)
|
|
35
|
+
raise "Expecting file #{file_path} to be a hash when loaded"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
merged_yaml_hash = merged_yaml_hash.deep_merge(file_hash)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return merged_yaml_hash
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @param file_path [String] file path
|
|
45
|
+
# @return [Boolean] whether or not it is a YAML file
|
|
46
|
+
def is_yaml_file?(file_path)
|
|
47
|
+
return (file_path.match(/\.ya?ml$/)) ? true : false
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require_relative 'helpers/string'
|
|
2
|
+
|
|
3
|
+
require_relative 'proxies/throttle_proxy'
|
|
4
|
+
require_relative 'proxies/mutex_proxy'
|
|
5
|
+
|
|
6
|
+
require_relative 'driver/driver'
|
|
7
|
+
|
|
8
|
+
#Adapters
|
|
9
|
+
require_relative 'driver/appium_adapter/driver'
|
|
10
|
+
require_relative 'driver/nokogiri_adapter/driver'
|
|
11
|
+
require_relative 'driver/selenium_adapter/driver'
|
|
12
|
+
|
|
13
|
+
module AutomationObject
|
|
14
|
+
#Driver Port
|
|
15
|
+
module Driver
|
|
16
|
+
extend self
|
|
17
|
+
|
|
18
|
+
def adapter
|
|
19
|
+
return @adapter if @adapter
|
|
20
|
+
self.adapter = :nokogiri
|
|
21
|
+
@adapter
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Sets adapter const will append _adapter if needed
|
|
25
|
+
# @param adapter_name [String] name of adapter wanted for composite creation
|
|
26
|
+
def adapter=(adapter_name)
|
|
27
|
+
adapter_name = adapter_name.to_s
|
|
28
|
+
adapter_name << '_adapter' unless adapter_name.match(/_adapter$/)
|
|
29
|
+
adapter_const = adapter_name.pascalize
|
|
30
|
+
|
|
31
|
+
@adapter = AutomationObject::Driver.const_get("#{adapter_const}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @param driver [Object] selenium or appium driver. default nil for Nokogiri
|
|
35
|
+
# @return [AutomationObject::Driver::Driver]
|
|
36
|
+
def new(driver = nil)
|
|
37
|
+
adapted_driver = Driver.new(self.adapter.new(driver))
|
|
38
|
+
|
|
39
|
+
#Add throttling and mutex proxies around adapter
|
|
40
|
+
return AutomationObject::Proxies::MutexProxy.new(
|
|
41
|
+
AutomationObject::Proxies::ThrottleProxy.new(adapted_driver))
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
require 'appium_lib'
|
|
2
|
+
|
|
3
|
+
require_relative '../../proxies/proxy'
|
|
4
|
+
require_relative '../helpers/selenium_driver_helper'
|
|
5
|
+
|
|
6
|
+
require_relative '../element'
|
|
7
|
+
require_relative 'element'
|
|
8
|
+
|
|
9
|
+
module AutomationObject
|
|
10
|
+
module Driver
|
|
11
|
+
module AppiumAdapter
|
|
12
|
+
#Driver proxy for Appium
|
|
13
|
+
#Conform Appium driver interface to what's expected of the Driver Port
|
|
14
|
+
class Driver < AutomationObject::Proxies::Proxy
|
|
15
|
+
include AutomationObject::Driver::SeleniumDriverHelper
|
|
16
|
+
|
|
17
|
+
# @param driver [Appium::Driver] Appium Driver
|
|
18
|
+
def initialize(driver)
|
|
19
|
+
@subject = driver
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Navigates current window to a given url
|
|
23
|
+
# @param url [String] navigate to the following url
|
|
24
|
+
# @return [void]
|
|
25
|
+
def get(url)
|
|
26
|
+
@subject.get(url)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @param script [String] JS to run
|
|
30
|
+
# @return [Object, nil]
|
|
31
|
+
def execute_script(script)
|
|
32
|
+
@subject.execute_script(script)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#Set timeout wait
|
|
36
|
+
# @param timeout [Integer] the timeout in seconds
|
|
37
|
+
# @return [void]
|
|
38
|
+
def set_wait(timeout = nil)
|
|
39
|
+
@subject.set_wait(timeout)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @param selector_type [Symbol] selector type (:css, :xpath, etc...)
|
|
43
|
+
# @param selector_path [String] path to element
|
|
44
|
+
# @return [Boolean] exists or not
|
|
45
|
+
def exists?(selector_type, selector_path)
|
|
46
|
+
return @subject.exists { @subject.find_element(selector_type, selector_path) }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @param selector_type [Symbol] selector type, :css, :xpath, etc...
|
|
50
|
+
# @param selector_path [String] path to element
|
|
51
|
+
# @return [AutomationObject::Driver::Element] element
|
|
52
|
+
def find_element(selector_type, selector_path)
|
|
53
|
+
element = @subject.find_element(selector_type, selector_path)
|
|
54
|
+
#Wrap element in the adapter interface
|
|
55
|
+
return AutomationObject::Driver::Element.new(Element.new(driver: self, element: element))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @param selector_type [Symbol] selector type, :css, :xpath, etc...
|
|
59
|
+
# @param selector_path [String] path to element
|
|
60
|
+
# @return [Array<AutomationObject::Driver::Element>] element
|
|
61
|
+
def find_elements(selector_type, selector_path)
|
|
62
|
+
elements = @subject.find_elements(selector_type, selector_path)
|
|
63
|
+
|
|
64
|
+
elements.map { |element|
|
|
65
|
+
#Wrap element in the adapter interface
|
|
66
|
+
AutomationObject::Driver::Element.new(Element.new(driver: self, element: element))
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @return [void]
|
|
71
|
+
def accept_prompt
|
|
72
|
+
@subject.alert_accept
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# @return [void]
|
|
76
|
+
def dismiss_prompt
|
|
77
|
+
@subject.alert_dismiss
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# @return [Boolean] whether or not browser is being used
|
|
81
|
+
def is_browser?
|
|
82
|
+
return @is_browser unless @is_browser == nil
|
|
83
|
+
@is_browser = false
|
|
84
|
+
|
|
85
|
+
#Now we need to check Appium's contexts to see if WEBVIEW is in available_contexts
|
|
86
|
+
available_contexts = @subject.available_contexts
|
|
87
|
+
available_contexts.each { |context|
|
|
88
|
+
if context.match(/^WEBVIEW_\d+$/)
|
|
89
|
+
@is_browser = true
|
|
90
|
+
break
|
|
91
|
+
end
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return @is_browser
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
#Window Handles Override
|
|
98
|
+
# @return [Array<String>] array of window handles
|
|
99
|
+
def window_handles
|
|
100
|
+
if @subject.device_is_android? and self.is_browser?
|
|
101
|
+
window_handles = @subject.window_handles
|
|
102
|
+
else
|
|
103
|
+
return @subject.available_contexts unless self.is_browser?
|
|
104
|
+
|
|
105
|
+
window_handles = []
|
|
106
|
+
@subject.available_contexts.each { |context|
|
|
107
|
+
window_handles.push(context) if context.match(/^WEBVIEW_\d+$/)
|
|
108
|
+
}
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
return window_handles
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
#Get window handle override
|
|
115
|
+
# @return [String] current window handle
|
|
116
|
+
def window_handle
|
|
117
|
+
return @subject.current_context unless self.is_browser?
|
|
118
|
+
|
|
119
|
+
if @subject.device_is_android?
|
|
120
|
+
return @subject.window_handle
|
|
121
|
+
else
|
|
122
|
+
return @subject.current_context
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
#Set window handle override
|
|
127
|
+
# @param handle_value [String] window handle value
|
|
128
|
+
# @return [void]
|
|
129
|
+
def window_handle=(handle_value)
|
|
130
|
+
if @subject.device_is_android?
|
|
131
|
+
@subject.switch_to.window(handle_value)
|
|
132
|
+
else
|
|
133
|
+
@subject.set_context(handle_value)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# @return [Boolean] document is complete
|
|
138
|
+
def document_complete?
|
|
139
|
+
return true unless self.is_browser? #Skip for non-browser Appium sessions
|
|
140
|
+
return @subject.execute_script('return document.readyState;') == 'complete'
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# @return [void]
|
|
144
|
+
def quit
|
|
145
|
+
@subject.driver_quit
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|