automation_object 0.5.0 → 0.5.1
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 +22 -11
- data/lib/automation_object/blue_print.rb +13 -12
- data/lib/automation_object/blue_print/composite/automatic_onload_modal.rb +9 -8
- data/lib/automation_object/blue_print/composite/base.rb +5 -4
- data/lib/automation_object/blue_print/composite/custom_method.rb +8 -7
- data/lib/automation_object/blue_print/composite/element.rb +6 -5
- data/lib/automation_object/blue_print/composite/element_array.rb +6 -5
- data/lib/automation_object/blue_print/composite/element_hash.rb +7 -6
- data/lib/automation_object/blue_print/composite/helpers/element_helper.rb +7 -7
- data/lib/automation_object/blue_print/composite/helpers/multiple_elements_helper.rb +5 -4
- data/lib/automation_object/blue_print/composite/hook.rb +9 -11
- data/lib/automation_object/blue_print/composite/hook_action.rb +25 -24
- data/lib/automation_object/blue_print/composite/hook_element_requirements.rb +14 -13
- data/lib/automation_object/blue_print/composite/modal.rb +11 -21
- data/lib/automation_object/blue_print/composite/screen.rb +22 -16
- data/lib/automation_object/blue_print/composite/top.rb +13 -12
- data/lib/automation_object/blue_print/composite/view.rb +27 -16
- data/lib/automation_object/blue_print/hash_adapter.rb +15 -11
- data/lib/automation_object/blue_print/hash_adapter/automatic_onload_modal.rb +12 -11
- data/lib/automation_object/blue_print/hash_adapter/composite.rb +28 -25
- data/lib/automation_object/blue_print/hash_adapter/custom_method.rb +11 -10
- data/lib/automation_object/blue_print/hash_adapter/element.rb +10 -9
- data/lib/automation_object/blue_print/hash_adapter/element_array.rb +10 -9
- data/lib/automation_object/blue_print/hash_adapter/element_hash.rb +11 -10
- data/lib/automation_object/blue_print/hash_adapter/helpers/element_helper.rb +20 -25
- data/lib/automation_object/blue_print/hash_adapter/helpers/multiple_elements_helper.rb +15 -14
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_error.rb +9 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb +19 -24
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate.rb +8 -5
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_allowed_keys.rb +7 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_element_presence_of.rb +28 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_instance_of.rb +12 -13
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb +27 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_presence_of.rb +9 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_screen_presence_of.rb +27 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_presence_of.rb +25 -21
- data/lib/automation_object/blue_print/hash_adapter/hook.rb +14 -11
- data/lib/automation_object/blue_print/hash_adapter/hook_action.rb +45 -47
- data/lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb +24 -28
- data/lib/automation_object/blue_print/hash_adapter/modal.rb +14 -13
- data/lib/automation_object/blue_print/hash_adapter/screen.rb +23 -22
- data/lib/automation_object/blue_print/hash_adapter/top.rb +16 -15
- data/lib/automation_object/blue_print/hash_adapter/view.rb +58 -4
- data/lib/automation_object/blue_print/yaml_adapter.rb +33 -34
- data/lib/automation_object/driver.rb +15 -13
- data/lib/automation_object/driver/appium_adapter/driver.rb +47 -46
- data/lib/automation_object/driver/appium_adapter/element.rb +29 -96
- data/lib/automation_object/driver/base.rb +4 -2
- data/lib/automation_object/driver/common_selenium/driver.rb +60 -0
- data/lib/automation_object/driver/common_selenium/element.rb +107 -0
- data/lib/automation_object/driver/common_selenium/element_geometry.rb +86 -0
- data/lib/automation_object/driver/driver.rb +60 -30
- data/lib/automation_object/driver/element.rb +70 -15
- data/lib/automation_object/driver/nokogiri_adapter/driver.rb +88 -34
- data/lib/automation_object/driver/nokogiri_adapter/element.rb +94 -16
- data/lib/automation_object/driver/nokogiri_adapter/error.rb +29 -8
- data/lib/automation_object/driver/nokogiri_adapter/{backup/form.rb → form.rb} +19 -6
- data/lib/automation_object/driver/nokogiri_adapter/request.rb +17 -0
- data/lib/automation_object/driver/nokogiri_adapter/session.rb +94 -0
- data/lib/automation_object/driver/nokogiri_adapter/window.rb +86 -0
- data/lib/automation_object/driver/selenium_adapter/driver.rb +36 -45
- data/lib/automation_object/driver/selenium_adapter/element.rb +15 -85
- data/lib/automation_object/dsl.rb +11 -28
- data/lib/automation_object/dsl/_base.rb +70 -0
- data/lib/automation_object/dsl/_proxy.rb +24 -0
- data/lib/automation_object/dsl/element.rb +34 -0
- data/lib/automation_object/dsl/element_array.rb +34 -0
- data/lib/automation_object/dsl/element_hash.rb +34 -0
- data/lib/automation_object/dsl/modal.rb +43 -0
- data/lib/automation_object/dsl/screen.rb +45 -0
- data/lib/automation_object/dsl/top.rb +25 -0
- data/lib/automation_object/framework.rb +28 -38
- data/lib/automation_object/helpers/composite.rb +30 -27
- data/lib/automation_object/helpers/composite_hook.rb +16 -15
- data/lib/automation_object/{blue_print/helpers/file_helper.rb → helpers/file.rb} +12 -12
- data/lib/automation_object/helpers/hash.rb +6 -5
- data/lib/automation_object/helpers/kernel.rb +11 -0
- data/lib/automation_object/helpers/{reflection_helper.rb → reflection.rb} +9 -8
- data/lib/automation_object/helpers/string.rb +25 -15
- data/lib/automation_object/{proxies → proxy}/mutex_proxy.rb +18 -21
- data/lib/automation_object/proxy/proxy.rb +23 -0
- data/lib/automation_object/proxy/throttle_proxy.rb +52 -0
- data/lib/automation_object/state.rb +11 -29
- data/lib/automation_object/state/{blue_print_adapter/composite.rb → composite/_base.rb} +35 -25
- data/lib/automation_object/state/{blue_print_adapter/helpers/element_helper.rb → composite/_common_element.rb} +11 -11
- data/lib/automation_object/state/composite/element.rb +22 -0
- data/lib/automation_object/state/composite/element_array.rb +27 -0
- data/lib/automation_object/state/composite/element_hash.rb +33 -0
- data/lib/automation_object/state/composite/element_proxy.rb +33 -0
- data/lib/automation_object/state/composite/helpers/window.rb +61 -0
- data/lib/automation_object/state/composite/helpers/window_manager.rb +60 -0
- data/lib/automation_object/state/composite/hook.rb +56 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_action.rb +10 -8
- data/lib/automation_object/state/composite/hook_actions/action_loop.rb +36 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_screen.rb +7 -5
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_to_previous_screen.rb +7 -5
- data/lib/automation_object/state/composite/hook_actions/close_modal.rb +29 -0
- data/lib/automation_object/state/composite/hook_actions/close_screen.rb +19 -0
- data/lib/automation_object/state/composite/hook_actions/element_requirement.rb +32 -0
- data/lib/automation_object/state/composite/hook_actions/new_screen.rb +35 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/possible_screen_changes.rb +8 -7
- data/lib/automation_object/state/composite/hook_actions/reset_screen.rb +14 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/show_modal.rb +7 -5
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/sleep.rb +4 -2
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/wait_for_elements.rb +7 -5
- data/lib/automation_object/state/composite/modal.rb +45 -0
- data/lib/automation_object/state/composite/screen.rb +58 -0
- data/lib/automation_object/state/composite/top.rb +51 -0
- data/lib/automation_object/state/error.rb +45 -6
- data/lib/automation_object/state/session.rb +25 -23
- data/lib/automation_object/step_definitions.rb +5 -3
- data/lib/automation_object/step_definitions/element.rb +77 -0
- data/lib/automation_object/step_definitions/element_array.rb +135 -0
- data/lib/automation_object/step_definitions/element_hash.rb +126 -0
- data/lib/automation_object/step_definitions/screen.rb +62 -0
- data/lib/automation_object/step_definitions/{cache.rb → support/cache.rb} +8 -6
- data/lib/automation_object/step_definitions/support/element_array.rb +40 -0
- data/lib/automation_object/step_definitions/support/element_hash.rb +41 -0
- data/lib/automation_object/step_definitions/{parse.rb → support/parse.rb} +8 -6
- data/lib/automation_object/version.rb +2 -1
- metadata +203 -103
- data/lib/automation_object/driver/helpers/selenium_driver_helper.rb +0 -41
- data/lib/automation_object/driver/helpers/selenium_element_helper.rb +0 -138
- data/lib/automation_object/driver/nokogiri_adapter/backup/driver.rb +0 -83
- data/lib/automation_object/driver/nokogiri_adapter/backup/element.rb +0 -66
- data/lib/automation_object/driver/nokogiri_adapter/backup/helpers/driver_element_helper.rb +0 -52
- data/lib/automation_object/driver/nokogiri_adapter/backup/session.rb +0 -115
- data/lib/automation_object/dsl/blue_print_adapter.rb +0 -16
- data/lib/automation_object/dsl/blue_print_adapter/composite.rb +0 -54
- data/lib/automation_object/dsl/blue_print_adapter/element.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/element_array.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/element_hash.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/modal.rb +0 -23
- data/lib/automation_object/dsl/blue_print_adapter/screen.rb +0 -26
- data/lib/automation_object/dsl/blue_print_adapter/top.rb +0 -19
- data/lib/automation_object/dsl/models.rb +0 -18
- data/lib/automation_object/dsl/proxies/element.rb +0 -16
- data/lib/automation_object/dsl/proxies/element_array.rb +0 -16
- data/lib/automation_object/dsl/proxies/element_hash.rb +0 -16
- data/lib/automation_object/dsl/proxies/helpers/composite_helper.rb +0 -74
- data/lib/automation_object/dsl/proxies/modal.rb +0 -17
- data/lib/automation_object/dsl/proxies/screen.rb +0 -17
- data/lib/automation_object/dsl/proxies/top.rb +0 -17
- data/lib/automation_object/proxies/proxy.rb +0 -20
- data/lib/automation_object/proxies/throttle_proxy.rb +0 -57
- data/lib/automation_object/state/blue_print_adapter.rb +0 -16
- data/lib/automation_object/state/blue_print_adapter/element.rb +0 -20
- data/lib/automation_object/state/blue_print_adapter/element_array.rb +0 -25
- data/lib/automation_object/state/blue_print_adapter/element_hash.rb +0 -31
- data/lib/automation_object/state/blue_print_adapter/element_proxy.rb +0 -28
- data/lib/automation_object/state/blue_print_adapter/helpers/screen_manager.rb +0 -137
- data/lib/automation_object/state/blue_print_adapter/helpers/window.rb +0 -39
- data/lib/automation_object/state/blue_print_adapter/hook.rb +0 -56
- data/lib/automation_object/state/blue_print_adapter/hook_actions/action_loop.rb +0 -35
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_modal.rb +0 -31
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_screen.rb +0 -19
- data/lib/automation_object/state/blue_print_adapter/hook_actions/element_requirement.rb +0 -34
- data/lib/automation_object/state/blue_print_adapter/hook_actions/new_screen.rb +0 -37
- data/lib/automation_object/state/blue_print_adapter/hook_actions/reset_screen.rb +0 -18
- data/lib/automation_object/state/blue_print_adapter/modal.rb +0 -26
- data/lib/automation_object/state/blue_print_adapter/screen.rb +0 -32
- data/lib/automation_object/state/blue_print_adapter/top.rb +0 -45
- data/lib/automation_object/step_definitions/action.rb +0 -21
- data/lib/automation_object/step_definitions/element/actions.rb +0 -87
- data/lib/automation_object/step_definitions/element/regex.rb +0 -24
- data/lib/automation_object/step_definitions/element/steps.rb +0 -67
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'proxy'
|
2
3
|
|
3
4
|
module AutomationObject
|
4
|
-
module
|
5
|
-
#Proxy class for protecting object with Mutex
|
5
|
+
module Proxy
|
6
|
+
# Proxy class for protecting object with Mutex
|
6
7
|
class MutexProxy < Proxy
|
7
8
|
def initialize(subject)
|
8
9
|
super
|
@@ -12,52 +13,48 @@ module AutomationObject
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def add_mutex(mutex_object)
|
15
|
-
unless mutex_object.is_a?(Mutex)
|
16
|
-
raise ArgumentError, 'Expecting mutex_object argument to be a Mutex object'
|
17
|
-
end
|
16
|
+
raise ArgumentError, 'Expecting mutex_object argument to be a Mutex object' unless mutex_object.is_a?(Mutex)
|
18
17
|
|
19
18
|
@mutexes << mutex_object
|
20
19
|
end
|
21
20
|
|
22
21
|
def delete_mutex(mutex_object)
|
23
|
-
unless mutex_object.is_a?(Mutex)
|
24
|
-
raise ArgumentError, 'Expecting mutex_object argument to be a Mutex object'
|
25
|
-
end
|
22
|
+
raise ArgumentError, 'Expecting mutex_object argument to be a Mutex object' unless mutex_object.is_a?(Mutex)
|
26
23
|
|
27
24
|
@mutexes.delete(mutex_object)
|
28
25
|
end
|
29
26
|
|
30
27
|
def method_missing(method_symbol, *args, &block)
|
31
|
-
exec_procedures =
|
32
|
-
exec_procedures.push(lambda
|
28
|
+
exec_procedures = []
|
29
|
+
exec_procedures.push(lambda do
|
33
30
|
execution_return = @subject.send(method_symbol, *args, &block)
|
34
|
-
return
|
35
|
-
|
31
|
+
return protect_object(execution_return)
|
32
|
+
end)
|
36
33
|
|
37
34
|
index = 0
|
38
|
-
@mutexes.each
|
35
|
+
@mutexes.each do |mutex|
|
39
36
|
index += 1
|
40
|
-
exec_procedures.push(lambda
|
37
|
+
exec_procedures.push(lambda do
|
41
38
|
mutex.synchronize do
|
42
39
|
index -= 1
|
43
40
|
exec_procedures[index].call
|
44
41
|
end
|
45
|
-
|
46
|
-
|
42
|
+
end)
|
43
|
+
end
|
47
44
|
|
48
|
-
|
45
|
+
exec_procedures.last.call
|
49
46
|
end
|
50
47
|
|
51
48
|
def protect_object(object)
|
52
49
|
return object if @skip_protection_classes.include?(object.class)
|
53
50
|
protected_object = MutexProxy.new(object)
|
54
51
|
|
55
|
-
@mutexes.each
|
52
|
+
@mutexes.each do |mutex|
|
56
53
|
protected_object.add_mutex(mutex)
|
57
|
-
|
54
|
+
end
|
58
55
|
|
59
|
-
|
56
|
+
protected_object
|
60
57
|
end
|
61
58
|
end
|
62
59
|
end
|
63
|
-
end
|
60
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module AutomationObject
|
3
|
+
module Proxy
|
4
|
+
# CompositeBase Proxy class for getting between another
|
5
|
+
class Proxy
|
6
|
+
instance_methods.each do |instance_method|
|
7
|
+
undef_method instance_method unless instance_method =~ /(^__|^send$|^object_id)/
|
8
|
+
end
|
9
|
+
|
10
|
+
# @param [Object] subject
|
11
|
+
def initialize(subject)
|
12
|
+
@subject = subject
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param [Symbol] method
|
16
|
+
# @param [Array, nil] args
|
17
|
+
# @param [Proc] block
|
18
|
+
def method_missing(method, *args, &block)
|
19
|
+
@subject.send(method, *args, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'proxy'
|
3
|
+
|
4
|
+
module AutomationObject
|
5
|
+
module Proxy
|
6
|
+
# Proxy class to throttle methods on the subject
|
7
|
+
class ThrottleProxy < Proxy
|
8
|
+
def initialize(subject)
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def throttle_methods
|
13
|
+
@throttle_methods ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing(method_symbol, *args, &block)
|
17
|
+
start_time = Time.new.to_f
|
18
|
+
execution_return = @subject.send(method_symbol, *args, &block)
|
19
|
+
throttle_speed(method_symbol, start_time)
|
20
|
+
execution_return
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_method_throttle(method_symbol, time)
|
24
|
+
raise ArgumentError, 'Expecting method_symbol argument to be a Symbol' unless method_symbol.is_a?(Symbol)
|
25
|
+
|
26
|
+
raise ArgumentError, 'Expecting time argument to be Numeric' unless time.is_a?(Numeric)
|
27
|
+
|
28
|
+
raise ArgumentError, "Expecting object to respond_to? #{method_symbol}" unless @subject.respond_to?(method_symbol)
|
29
|
+
|
30
|
+
throttle_methods[method_symbol] = time
|
31
|
+
end
|
32
|
+
|
33
|
+
# Delete throttle that exists
|
34
|
+
# @param method_symbol [Symbol] method symbol to remove throttle from
|
35
|
+
def delete_method_throttle(method_symbol)
|
36
|
+
throttle_methods.delete(method_symbol)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Method to sleep the difference between actual and throttle time
|
40
|
+
# @param method_symbol [Symbol] method that is to be throttled
|
41
|
+
# @param start_time [Float] start time as float
|
42
|
+
# @return [nil]
|
43
|
+
def throttle_speed(method_symbol, start_time)
|
44
|
+
return unless throttle_methods.key?(method_symbol)
|
45
|
+
total_time_taken = Time.new.to_f - start_time
|
46
|
+
|
47
|
+
sleep_time = throttle_methods[method_symbol] - total_time_taken
|
48
|
+
sleep(sleep_time) if sleep_time.positive?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,37 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'state/session'
|
2
3
|
|
3
4
|
module AutomationObject
|
4
|
-
#State Port, following port/adapter pattern
|
5
|
-
#
|
5
|
+
# State Port, following port/adapter pattern
|
6
|
+
# Composite adapts the state to the blueprint
|
6
7
|
module State
|
7
|
-
|
8
|
+
module_function
|
8
9
|
|
9
|
-
#
|
10
|
-
|
11
|
-
return @adapter if @adapter
|
12
|
-
self.adapter = :blue_print
|
13
|
-
@adapter
|
14
|
-
end
|
15
|
-
|
16
|
-
# Sets adapter const will append _adapter if needed
|
17
|
-
# @param adapter_name [String] name of adapter wanted for composite creation
|
18
|
-
def adapter=(adapter_name)
|
19
|
-
adapter_name = adapter_name.to_s
|
20
|
-
adapter_name << '_adapter' unless adapter_name.match(/_adapter$/)
|
21
|
-
adapter_const = adapter_name.pascalize
|
22
|
-
|
23
|
-
require_relative "state/#{adapter_name}"
|
24
|
-
@adapter = AutomationObject::State.const_get("#{adapter_const}")
|
25
|
-
end
|
26
|
-
|
27
|
-
# Creates/returns a new session, attaches driver, and composite adapter
|
28
|
-
# Will use a composite to direct the other layers (ie BluePrint)
|
29
|
-
# @param blue_prints [AutomationObject::BluePrint::Composite::Top] Top composite interface
|
10
|
+
# Creates/returns a new session, attaches driver, and composite
|
11
|
+
# Will use a composite to help control the state
|
30
12
|
# @param driver [AutomationObject::Driver::Driver] driver interface
|
31
|
-
# @
|
32
|
-
|
33
|
-
|
34
|
-
|
13
|
+
# @param blue_prints [AutomationObject::BluePrint::Composite::Top] Top composite interface
|
14
|
+
# # @return [AutomationObject::State::Session] Session instance
|
15
|
+
def create(driver, blue_prints)
|
16
|
+
Session.new(driver, blue_prints)
|
35
17
|
end
|
36
18
|
end
|
37
|
-
end
|
19
|
+
end
|
@@ -1,22 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative '../../helpers/composite'
|
2
|
-
#require_relative 'top'
|
3
|
-
#require_relative 'screen'
|
4
3
|
|
5
4
|
module AutomationObject
|
6
5
|
module State
|
7
|
-
module
|
8
|
-
#Parent composite class
|
9
|
-
class
|
10
|
-
|
6
|
+
module Composite
|
7
|
+
# Parent composite class
|
8
|
+
class Base < ::AutomationObject::Composite
|
9
|
+
# @return [AutomationObject::State::Session]
|
10
|
+
attr_accessor :session
|
11
11
|
|
12
|
-
# @
|
12
|
+
# @return [AutomationObject::BluePrint::Composite::]
|
13
|
+
attr_accessor :blue_prints
|
14
|
+
|
15
|
+
# @return [AutomationObject::Driver::Driver]
|
16
|
+
attr_accessor :driver
|
17
|
+
|
18
|
+
# @param session [AutomationObject::State::Session] session
|
13
19
|
# @param driver [AutomationObject::Driver] driver
|
20
|
+
# @param blue_prints [AutomationObject::BluePrint::Composite] blue print composite
|
14
21
|
# @param name [Symbol] name of composite element
|
15
22
|
# @param parent [Object, nil] parent composite object
|
16
23
|
# @param location [String] string location for error/debugging purposes
|
17
|
-
def initialize(
|
18
|
-
self.
|
24
|
+
def initialize(session, driver, blue_prints, name = :top, parent = nil, location = 'top')
|
25
|
+
self.session = session
|
19
26
|
self.driver = driver
|
27
|
+
self.blue_prints = blue_prints
|
20
28
|
|
21
29
|
super(name, parent, location)
|
22
30
|
end
|
@@ -25,9 +33,12 @@ module AutomationObject
|
|
25
33
|
# @param name [Symbol] name of child
|
26
34
|
# @param args [Hash] args
|
27
35
|
def get_child(name, args)
|
28
|
-
child_location =
|
36
|
+
child_location = location + "[#{name}]"
|
29
37
|
|
30
|
-
|
38
|
+
args.fetch(:interface).new(session,
|
39
|
+
driver,
|
40
|
+
blue_prints.send(name),
|
41
|
+
name, self, child_location)
|
31
42
|
end
|
32
43
|
|
33
44
|
# Overriding base get_children method
|
@@ -35,31 +46,30 @@ module AutomationObject
|
|
35
46
|
# @param args [Hash] args
|
36
47
|
# @return children [Array<Composite>] return children and names
|
37
48
|
def get_children(name, args)
|
38
|
-
children_hash =
|
49
|
+
children_hash = {}
|
39
50
|
|
40
|
-
|
41
|
-
child_location =
|
51
|
+
blue_prints.send(name).each do |child_key, child_blue_prints|
|
52
|
+
child_location = location + "[#{child_key}]"
|
42
53
|
|
43
|
-
children_hash[child_key] = args.fetch(:interface).new(
|
44
|
-
|
45
|
-
|
46
|
-
self,
|
47
|
-
|
48
|
-
}
|
54
|
+
children_hash[child_key] = args.fetch(:interface).new(session,
|
55
|
+
driver,
|
56
|
+
child_blue_prints,
|
57
|
+
name, self, child_location)
|
58
|
+
end
|
49
59
|
|
50
|
-
|
60
|
+
children_hash
|
51
61
|
end
|
52
62
|
|
53
63
|
# Recursive function to reach parent screen
|
54
64
|
# Can return nil if above a screen!
|
55
65
|
# @return [AutomationObject::State::BluePrintAdapter::Screen,nil]
|
56
66
|
def screen
|
57
|
-
return nil if
|
67
|
+
return nil if is_a?(Top)
|
58
68
|
|
59
|
-
#Should recursively call top until parent is nil
|
60
|
-
|
69
|
+
# Should recursively call top until parent is nil
|
70
|
+
is_a?(Screen) ? self : parent.screen
|
61
71
|
end
|
62
72
|
end
|
63
73
|
end
|
64
74
|
end
|
65
|
-
end
|
75
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'hook'
|
2
3
|
|
3
4
|
module AutomationObject
|
4
5
|
module State
|
5
|
-
|
6
|
-
|
7
|
-
module
|
6
|
+
module Composite
|
7
|
+
# Helper module for Element composite classes
|
8
|
+
module CommonElement
|
8
9
|
def method_hook?(name)
|
9
|
-
|
10
|
+
blue_prints.method_hooks.key?(name)
|
10
11
|
end
|
11
12
|
|
12
13
|
# @return [Hash<Hook>] array of Hook that are defined under the element
|
@@ -14,18 +15,17 @@ module AutomationObject
|
|
14
15
|
return @method_hooks if @method_hooks
|
15
16
|
|
16
17
|
@method_hooks = {}
|
17
|
-
|
18
|
+
blue_prints.method_hooks.each do |key, blue_prints|
|
18
19
|
@method_hooks[key] = Hook.new(blue_prints,
|
19
|
-
|
20
|
+
driver,
|
20
21
|
key,
|
21
22
|
self,
|
22
|
-
|
23
|
-
|
23
|
+
location + "[#{key}]")
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
+
@method_hooks
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
31
|
-
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '_base'
|
3
|
+
require_relative '_common_element'
|
4
|
+
|
5
|
+
require_relative 'element_proxy'
|
6
|
+
|
7
|
+
module AutomationObject
|
8
|
+
module State
|
9
|
+
module Composite
|
10
|
+
# Element composite for managing state
|
11
|
+
class Element < Base
|
12
|
+
include CommonElement
|
13
|
+
|
14
|
+
# @return [AutomationObject::State::Composite::ElementProxy] Selenium proxy
|
15
|
+
def load
|
16
|
+
element = driver.find_element(*blue_prints.selector_params)
|
17
|
+
ElementProxy.new(self, element)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '_base'
|
3
|
+
require_relative '_common_element'
|
4
|
+
|
5
|
+
require_relative 'element_proxy'
|
6
|
+
|
7
|
+
module AutomationObject
|
8
|
+
module State
|
9
|
+
module Composite
|
10
|
+
# Element array composite for managing state
|
11
|
+
class ElementArray < Base
|
12
|
+
include CommonElement
|
13
|
+
|
14
|
+
# @return [Array<AutomationObject::State::Composite::ElementProxy>] Selenium proxy
|
15
|
+
def load
|
16
|
+
elements = driver.find_elements(*blue_prints.selector_params)
|
17
|
+
|
18
|
+
wrapped_elements = elements.map do |element|
|
19
|
+
ElementProxy.new(self, element)
|
20
|
+
end
|
21
|
+
|
22
|
+
wrapped_elements
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '_base'
|
3
|
+
require_relative '_common_element'
|
4
|
+
|
5
|
+
require_relative 'element_proxy'
|
6
|
+
|
7
|
+
module AutomationObject
|
8
|
+
module State
|
9
|
+
module Composite
|
10
|
+
# Element hash composite for managing state
|
11
|
+
class ElementHash < Base
|
12
|
+
include CommonElement
|
13
|
+
|
14
|
+
# @return [Hash<String, AutomationObject::State::Composite::ElementProxy>] Selenium proxy
|
15
|
+
def load
|
16
|
+
elements = driver.find_elements(*blue_prints.selector_params)
|
17
|
+
elements_hash = {}
|
18
|
+
|
19
|
+
elements.each do |element|
|
20
|
+
# Want to wrap element, before sending for method!
|
21
|
+
# That will help us include custom methods, etc...
|
22
|
+
wrapped_element = ElementProxy.new(self, element)
|
23
|
+
hash_key = wrapped_element.send(blue_prints.define_elements_by) # Send to wrapped state proxy
|
24
|
+
|
25
|
+
elements_hash[hash_key] = wrapped_element
|
26
|
+
end
|
27
|
+
|
28
|
+
elements_hash
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../../proxy/proxy'
|
3
|
+
|
4
|
+
module AutomationObject
|
5
|
+
module State
|
6
|
+
module Composite
|
7
|
+
# Proxy class to allow for usage of hooks
|
8
|
+
class ElementProxy < ::AutomationObject::Proxy::Proxy
|
9
|
+
def initialize(composite, element)
|
10
|
+
@composite = composite
|
11
|
+
@subject = element
|
12
|
+
end
|
13
|
+
|
14
|
+
# Overiding base method to run possible hooks
|
15
|
+
def method_missing(method_symbol, *args, &block)
|
16
|
+
# Run before hook if needed
|
17
|
+
@composite.method_hooks[method_symbol].before if @composite.method_hook?(method_symbol)
|
18
|
+
|
19
|
+
subject_return = @subject.send(method_symbol, *args, &block)
|
20
|
+
|
21
|
+
# Run after hook if needed
|
22
|
+
@composite.method_hooks[method_symbol].after if @composite.method_hook?(method_symbol)
|
23
|
+
|
24
|
+
subject_return
|
25
|
+
end
|
26
|
+
|
27
|
+
def respond_to_missing?(method, include_private = false)
|
28
|
+
@subject.respond_to_missing?(method, include_private)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|