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