automation_object 0.8.1 → 0.8.2
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/blue_print.rb +9 -2
- data/lib/automation_object/blue_print/composite/helpers/container_helper.rb +2 -7
- data/lib/automation_object/blue_print/composite/modal.rb +0 -25
- data/lib/automation_object/blue_print/composite/screen.rb +0 -20
- data/lib/automation_object/blue_print/hash_adapter.rb +1 -1
- data/lib/automation_object/blue_print/hash_adapter/element.rb +0 -1
- data/lib/automation_object/blue_print/page_object_adapter.rb +55 -0
- data/lib/automation_object/blue_print/page_object_adapter/automatic_modal_change.rb +34 -0
- data/lib/automation_object/blue_print/page_object_adapter/composite.rb +93 -0
- data/lib/automation_object/blue_print/page_object_adapter/custom_method.rb +27 -0
- data/lib/automation_object/blue_print/page_object_adapter/element.rb +16 -0
- data/lib/automation_object/blue_print/page_object_adapter/element_array.rb +18 -0
- data/lib/automation_object/blue_print/page_object_adapter/element_hash.rb +25 -0
- data/lib/automation_object/blue_print/page_object_adapter/helpers/element_helper.rb +62 -0
- data/lib/automation_object/blue_print/page_object_adapter/helpers/multiple_elements_helper.rb +37 -0
- data/lib/automation_object/blue_print/page_object_adapter/hook.rb +27 -0
- data/lib/automation_object/blue_print/page_object_adapter/hook_action.rb +112 -0
- data/lib/automation_object/blue_print/page_object_adapter/hook_element_requirements.rb +56 -0
- data/lib/automation_object/blue_print/page_object_adapter/modal.rb +27 -0
- data/lib/automation_object/blue_print/page_object_adapter/screen.rb +34 -0
- data/lib/automation_object/blue_print/page_object_adapter/top.rb +52 -0
- data/lib/automation_object/dsl/_error.rb +0 -27
- data/lib/automation_object/dsl/modal.rb +2 -2
- data/lib/automation_object/dsl/screen.rb +7 -6
- data/lib/automation_object/framework.rb +1 -8
- data/lib/automation_object/helpers/composite.rb +4 -4
- data/lib/automation_object/page_object.rb +15 -0
- data/lib/automation_object/page_object/base.rb +22 -0
- data/lib/automation_object/page_object/configuration.rb +35 -0
- data/lib/automation_object/page_object/element.rb +10 -0
- data/lib/automation_object/page_object/element_array.rb +10 -0
- data/lib/automation_object/page_object/element_hash.rb +10 -0
- data/lib/automation_object/page_object/modal.rb +10 -0
- data/lib/automation_object/page_object/screen.rb +10 -0
- data/lib/automation_object/step_definitions/element.rb +24 -18
- data/lib/automation_object/step_definitions/element_array.rb +28 -21
- data/lib/automation_object/step_definitions/element_hash.rb +28 -21
- data/lib/automation_object/step_definitions/support/element_array.rb +2 -2
- data/lib/automation_object/step_definitions/support/element_hash.rb +2 -2
- data/lib/automation_object/version.rb +1 -1
- metadata +30 -7
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AutomationObject
|
4
|
+
module BluePrint
|
5
|
+
module PageObjectAdapter
|
6
|
+
# Helper module for multiple element composite classes
|
7
|
+
module MultipleElementsHelper
|
8
|
+
# @return [Range, nil] gives range for limiting multiple elements or nil
|
9
|
+
def custom_range
|
10
|
+
custom_range = hash[:custom_range]
|
11
|
+
|
12
|
+
case custom_range
|
13
|
+
when String
|
14
|
+
integer_array = custom_range.split('..').map { |number| Integer(number) }
|
15
|
+
return integer_array[0]..integer_array[1]
|
16
|
+
when Hash
|
17
|
+
return custom_range[:start].to_i..custom_range[:end].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Symbol, nil] gives element method to remove duplicates on or nil
|
24
|
+
def remove_duplicates
|
25
|
+
remove_duplicates = hash[:remove_duplicates]
|
26
|
+
|
27
|
+
case remove_duplicates
|
28
|
+
when Symbol, String
|
29
|
+
return remove_duplicates.to_sym
|
30
|
+
else
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
require_relative 'hook_element_requirements'
|
6
|
+
|
7
|
+
module AutomationObject
|
8
|
+
module BluePrint
|
9
|
+
module PageObjectAdapter
|
10
|
+
# Hook composite
|
11
|
+
class Hook < Composite
|
12
|
+
# @return [Array<HookElementRequirements>] array of element requirements
|
13
|
+
def live?
|
14
|
+
return @live if defined? @live
|
15
|
+
|
16
|
+
children = get_property(:live?)
|
17
|
+
children = children.is_a?(Array) ? children : []
|
18
|
+
|
19
|
+
@live = create_array_children(:live, children,
|
20
|
+
interface: HookElementRequirements,
|
21
|
+
location: location + '[live?]')
|
22
|
+
@live
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
module AutomationObject
|
6
|
+
module BluePrint
|
7
|
+
module PageObjectAdapter
|
8
|
+
# HockAction composite
|
9
|
+
class HockAction < Composite
|
10
|
+
# Get the order to run the hook in
|
11
|
+
# @return [Array<Symbol>] list of hook methods to run in given order
|
12
|
+
def hook_order
|
13
|
+
hash.keys
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get length of hook actions
|
17
|
+
# @return [Integer] length of hook actions
|
18
|
+
def length
|
19
|
+
hash.keys.length
|
20
|
+
end
|
21
|
+
|
22
|
+
# See if hook actions are empty
|
23
|
+
# @return [Boolean] if hook actions are empty
|
24
|
+
def empty?
|
25
|
+
hash.keys.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Symbol, nil] screen to change to
|
29
|
+
def change_screen
|
30
|
+
change_screen = hash[:change_screen]
|
31
|
+
|
32
|
+
case change_screen
|
33
|
+
when Symbol, String
|
34
|
+
return change_screen.to_sym
|
35
|
+
else
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Symbol, nil] new screen
|
41
|
+
def new_screen
|
42
|
+
new_screen = hash[:new_screen]
|
43
|
+
|
44
|
+
case new_screen
|
45
|
+
when Symbol, String
|
46
|
+
return new_screen.to_sym
|
47
|
+
else
|
48
|
+
return nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Boolean]
|
53
|
+
def close_screen
|
54
|
+
hash[:close_screen] ||= false
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Boolean]
|
58
|
+
def close_modal
|
59
|
+
hash[:close_modal] ||= false
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Boolean]
|
63
|
+
def change_to_previous_screen
|
64
|
+
hash[:change_to_previous_screen] ||= false
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [Symbol, nil]
|
68
|
+
def show_modal
|
69
|
+
show_modal = hash[:show_modal]
|
70
|
+
|
71
|
+
case show_modal
|
72
|
+
when Symbol, String
|
73
|
+
return show_modal.to_sym
|
74
|
+
else
|
75
|
+
return nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# @return [Array]
|
80
|
+
def possible_screen_changes
|
81
|
+
return hash[:possible_screen_changes].map(&:to_sym) if hash[:possible_screen_changes].is_a?(Array)
|
82
|
+
|
83
|
+
[]
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [Boolean] reset the screen?
|
87
|
+
def reset_screen
|
88
|
+
hash[:reset_screen] ||= false
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [Numeric] amount of time to sleep
|
92
|
+
def sleep
|
93
|
+
hash[:sleep] ||= 0
|
94
|
+
end
|
95
|
+
|
96
|
+
# Custom method for array of children instead of Hash
|
97
|
+
# @return [Array<HookElementRequirements>] array of wait for element children
|
98
|
+
def wait_for_elements
|
99
|
+
return @wait_for_elements if defined? @wait_for_elements
|
100
|
+
wait_for_elements = hash[:wait_for_elements]
|
101
|
+
|
102
|
+
children = wait_for_elements.is_a?(Array) ? wait_for_elements : []
|
103
|
+
@wait_for_elements = create_array_children(:wait_for_elements, children,
|
104
|
+
interface: HookElementRequirements,
|
105
|
+
location: location + '[wait_for_elements]')
|
106
|
+
|
107
|
+
@wait_for_elements
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
module AutomationObject
|
6
|
+
module BluePrint
|
7
|
+
module PageObjectAdapter
|
8
|
+
# HookElementRequirements composite
|
9
|
+
class HookElementRequirements < Composite
|
10
|
+
# Get the order to run the hook in
|
11
|
+
# @return [Array<Symbol>] list of hook methods to run in given order
|
12
|
+
def hook_order
|
13
|
+
hook_order = [:exists?] # Always put exists? first
|
14
|
+
|
15
|
+
hash.each_key do |hook_name|
|
16
|
+
hook_order.push(hook_name) unless %i[element_name exists?].include?(hook_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
hook_order
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get element requirement
|
23
|
+
# @param name [Symbol] name of requested requirement
|
24
|
+
def requirement(name)
|
25
|
+
hash[name] ||= nil
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get name of the element
|
29
|
+
# @return [Symbol] name of element
|
30
|
+
def element_name
|
31
|
+
element_name = hash[:element_name]
|
32
|
+
|
33
|
+
case element_name
|
34
|
+
when Symbol, String
|
35
|
+
return element_name.to_sym
|
36
|
+
else
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Convience for getting element blueprints
|
42
|
+
# @return [AutomationObject::BluePrint::HashAdapter::Element]
|
43
|
+
def element_blueprints(composite_object = nil)
|
44
|
+
composite_object = self unless composite_object
|
45
|
+
|
46
|
+
# Traverse!
|
47
|
+
return composite_object.elements[element_name] if composite_object.hash[:elements].is_a?(Hash)
|
48
|
+
|
49
|
+
return element_blueprints(composite_object.parent) if composite_object.parent
|
50
|
+
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
require_relative 'hook'
|
6
|
+
require_relative 'element'
|
7
|
+
require_relative 'element_array'
|
8
|
+
require_relative 'element_hash'
|
9
|
+
|
10
|
+
module AutomationObject
|
11
|
+
module BluePrint
|
12
|
+
module PageObjectAdapter
|
13
|
+
# Modal composite
|
14
|
+
class Modal < Composite
|
15
|
+
# Relationships
|
16
|
+
has_one :load, interface: Hook
|
17
|
+
has_one :accept, interface: Hook
|
18
|
+
has_one :dismiss, interface: Hook
|
19
|
+
|
20
|
+
has_many :modals, interface: Modal
|
21
|
+
has_many :elements, interface: Element
|
22
|
+
has_many :element_arrays, interface: ElementArray
|
23
|
+
has_many :element_hashes, interface: ElementHash
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
|
5
|
+
require_relative 'modal'
|
6
|
+
require_relative 'hook'
|
7
|
+
require_relative 'element'
|
8
|
+
require_relative 'element_array'
|
9
|
+
require_relative 'element_hash'
|
10
|
+
|
11
|
+
module AutomationObject
|
12
|
+
module BluePrint
|
13
|
+
module PageObjectAdapter
|
14
|
+
# Screen composite
|
15
|
+
class Screen < Composite
|
16
|
+
# Relationships
|
17
|
+
has_one :load, interface: Hook
|
18
|
+
has_one :accept, interface: Hook
|
19
|
+
has_one :dismiss, interface: Hook
|
20
|
+
|
21
|
+
has_many :modals, interface: Modal
|
22
|
+
has_many :elements, interface: Element
|
23
|
+
has_many :element_arrays, interface: ElementArray
|
24
|
+
has_many :element_hashes, interface: ElementHash
|
25
|
+
|
26
|
+
# @return [Array<Symbol>] array of screens where screen can automatically change to
|
27
|
+
def automatic_screen_changes
|
28
|
+
screen_array = get_property(:automatic_screen_changes) || []
|
29
|
+
screen_array.map(&:to_sym)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'composite'
|
4
|
+
require_relative 'screen'
|
5
|
+
|
6
|
+
module AutomationObject
|
7
|
+
module BluePrint
|
8
|
+
module PageObjectAdapter
|
9
|
+
# Top composite
|
10
|
+
class Top < Composite
|
11
|
+
# Relationships
|
12
|
+
has_many :screens, interface: Screen
|
13
|
+
|
14
|
+
def initialize(defined_module)
|
15
|
+
super(defined_module, defined_module.const_get(:Configuration))
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String, nil] base url to navigate to upon framework creation
|
19
|
+
def base_url
|
20
|
+
get_property(:base_url) || nil
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Symbol, nil] default screen to be set when framework is created
|
24
|
+
def default_screen
|
25
|
+
default_screen = get_property(:default_screen)
|
26
|
+
|
27
|
+
case default_screen
|
28
|
+
when Symbol, String
|
29
|
+
return default_screen.to_sym
|
30
|
+
else
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Numeric] sleep when transitioning screens
|
36
|
+
def screen_transition_sleep
|
37
|
+
get_property(:screen_transition_sleep) || 0
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Hash] driver methods to throttle
|
41
|
+
def throttle_driver_methods
|
42
|
+
get_property(:throttle_driver_methods) || {}
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [Hash] element methods to throttle
|
46
|
+
def throttle_element_methods
|
47
|
+
get_property(:throttle_element_methods) || {}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -4,24 +4,6 @@ module AutomationObject
|
|
4
4
|
module Dsl
|
5
5
|
# Errors related to interacting with the DSL
|
6
6
|
module Error
|
7
|
-
# Error for automatically reaching screen
|
8
|
-
class AutoReachScreenError < StandardError
|
9
|
-
# @param name [Symbol,String] screen name
|
10
|
-
def initialize(name)
|
11
|
-
message = "#{name}, unable to automatically reach screen"
|
12
|
-
super(message)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Error for automatically reaching modal
|
17
|
-
class AutoReachModalError < StandardError
|
18
|
-
# @param name [Symbol,String] screen name
|
19
|
-
def initialize(name)
|
20
|
-
message = "#{name}, unable to automatically reach modal"
|
21
|
-
super(message)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
7
|
# Error for non-existent screen
|
26
8
|
class ScreenDoesNotExistError < StandardError
|
27
9
|
# @param name [Symbol,String] screen name
|
@@ -31,15 +13,6 @@ module AutomationObject
|
|
31
13
|
end
|
32
14
|
end
|
33
15
|
|
34
|
-
# Error for non-existent modal
|
35
|
-
class ModalDoesNotExistError < StandardError
|
36
|
-
# @param name [Symbol,String] modal name
|
37
|
-
def initialize(name)
|
38
|
-
message = "#{name} modal does not exist"
|
39
|
-
super(message)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
16
|
# Error for non-existent element
|
44
17
|
class ElementDoesNotExistError < StandardError
|
45
18
|
# @param name [Symbol,String] element name
|
@@ -46,9 +46,9 @@ module AutomationObject
|
|
46
46
|
# Go to this modal
|
47
47
|
# Will try to automatically reach it, will throw error if it cannot
|
48
48
|
# @raise [AutomationObject::Dsl::Error::AutoReachModalError]
|
49
|
-
# @return [
|
49
|
+
# @return [Boolean]
|
50
50
|
def go
|
51
|
-
|
51
|
+
@state.go
|
52
52
|
end
|
53
53
|
|
54
54
|
# Retrieve element from composite
|
@@ -55,21 +55,22 @@ module AutomationObject
|
|
55
55
|
# Go to this screen
|
56
56
|
# Will try to automatically reach it, will throw error if it cannot
|
57
57
|
# @raise [AutomationObject::Dsl::Error::AutoReachScreenError]
|
58
|
-
# @return [
|
58
|
+
# @return [Boolean]
|
59
59
|
def go
|
60
|
-
|
60
|
+
@state.go
|
61
61
|
end
|
62
62
|
|
63
|
-
# Retrieve modal from composite
|
63
|
+
# Retrieve modal or self from composite
|
64
64
|
# @param name [String, Symbol] name of modal
|
65
|
-
# @
|
66
|
-
# @return [AutomationObject::Dsl::ModalProxy]
|
65
|
+
# @return [AutomationObject::Dsl::ModalProxy, AutomationObject::Dsl::ScreenProxy]
|
67
66
|
def modal(name)
|
68
67
|
name = name.to_sym
|
69
68
|
raise AutomationObject::Dsl::Error::ModalDoesNotExistError, name unless @subject.to_h.include?(name)
|
70
69
|
|
71
70
|
@state.utilize
|
72
|
-
@subject.send(name)
|
71
|
+
return @subject.send(name) if @subject.send(name)
|
72
|
+
|
73
|
+
self
|
73
74
|
end
|
74
75
|
|
75
76
|
# Retrieve element from composite
|
@@ -54,17 +54,10 @@ module AutomationObject
|
|
54
54
|
|
55
55
|
# BluePrints (UI configurations) wrapped in an composite
|
56
56
|
# Composite provides a common interface for all adapters
|
57
|
-
# @param value [String, Hash] String to YAML files or Hash configuration
|
57
|
+
# @param value [String, Hash] String to YAML files, PageObject, or Hash configuration
|
58
58
|
# @return [AutomationObject::BluePrint::Composite::Top] top composite object
|
59
59
|
undef :blue_prints= if defined? :blue_prints=
|
60
60
|
def blue_prints=(value)
|
61
|
-
case value
|
62
|
-
when String
|
63
|
-
BluePrint.adapter = :yaml
|
64
|
-
when Hash
|
65
|
-
BluePrint.adapter = :hash
|
66
|
-
end
|
67
|
-
|
68
61
|
@blue_prints = BluePrint.create(value)
|
69
62
|
end
|
70
63
|
|