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
data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/show_modal.rb
RENAMED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'action_loop'
|
2
3
|
|
3
4
|
module AutomationObject
|
4
5
|
module State
|
5
|
-
module
|
6
|
+
module Composite
|
7
|
+
# Show modal hook loop
|
6
8
|
class ShowModal < ActionLoop
|
7
9
|
def initialize(args = {})
|
8
10
|
super
|
@@ -10,11 +12,11 @@ module AutomationObject
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def single_run
|
13
|
-
new_modal =
|
15
|
+
new_modal = composite.screen.modals[@new_modal_name]
|
14
16
|
|
15
17
|
if new_modal.load.live? != false
|
16
|
-
|
17
|
-
|
18
|
+
composite.screen.current_modal = @new_modal_name
|
19
|
+
composite.screen.modal = new_modal
|
18
20
|
return true
|
19
21
|
else
|
20
22
|
return false
|
@@ -23,4 +25,4 @@ module AutomationObject
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
26
|
-
end
|
28
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'action_loop'
|
2
3
|
|
3
4
|
module AutomationObject
|
4
5
|
module State
|
5
|
-
module
|
6
|
+
module Composite
|
7
|
+
# Sleep hook loop
|
6
8
|
class Sleep < ActionLoop
|
7
9
|
def initialize(args = {})
|
8
10
|
super
|
@@ -15,4 +17,4 @@ module AutomationObject
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
18
|
-
end
|
20
|
+
end
|
data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/wait_for_elements.rb
RENAMED
@@ -1,20 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'action_loop'
|
2
3
|
|
3
4
|
module AutomationObject
|
4
5
|
module State
|
5
|
-
module
|
6
|
+
module Composite
|
7
|
+
# Wait for elements hook loop
|
6
8
|
class WaitForElements < ActionLoop
|
7
9
|
def single_run
|
8
|
-
|
10
|
+
blue_prints.each do |hook_element_requirement|
|
9
11
|
hook_element_requirement = ElementRequirement.new(blue_prints: hook_element_requirement,
|
10
12
|
composite: self,
|
11
13
|
loops: 1)
|
12
14
|
return false unless hook_element_requirement.run
|
13
|
-
|
15
|
+
end
|
14
16
|
|
15
|
-
|
17
|
+
true
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
20
|
-
end
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '_base'
|
3
|
+
require_relative '../error'
|
4
|
+
|
5
|
+
require_relative 'element'
|
6
|
+
require_relative 'element_array'
|
7
|
+
require_relative 'element_hash'
|
8
|
+
|
9
|
+
module AutomationObject
|
10
|
+
module State
|
11
|
+
module Composite
|
12
|
+
# Modal composite for managing state
|
13
|
+
class Modal < Base
|
14
|
+
has_one :load, interface: Hook
|
15
|
+
|
16
|
+
has_many :elements, interface: Element
|
17
|
+
has_many :element_arrays, interface: ElementArray
|
18
|
+
has_many :element_hashes, interface: ElementHash
|
19
|
+
|
20
|
+
def get(type, name)
|
21
|
+
case type
|
22
|
+
when :element
|
23
|
+
elements[name].load
|
24
|
+
when :element_array
|
25
|
+
element_arrays[name].load
|
26
|
+
when :element_hash
|
27
|
+
element_hashes[name].load
|
28
|
+
else
|
29
|
+
raise AutomationObject::State::UndefinedLoadTypeError
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Whether or not modal is active
|
34
|
+
# @return [Boolean]
|
35
|
+
attr_accessor :active
|
36
|
+
|
37
|
+
undef :active if defined? :active
|
38
|
+
# @return [Boolean] screen is active or not
|
39
|
+
def active
|
40
|
+
@active ||= false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '_base'
|
3
|
+
require_relative '../error'
|
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 State
|
13
|
+
module Composite
|
14
|
+
# Screen composite for managing state
|
15
|
+
class Screen < Base
|
16
|
+
attr_accessor :modal
|
17
|
+
|
18
|
+
has_one :load, interface: Hook
|
19
|
+
|
20
|
+
# Children for this composite
|
21
|
+
has_many :modals, interface: Modal
|
22
|
+
|
23
|
+
has_many :elements, interface: Element
|
24
|
+
has_many :element_arrays, interface: ElementArray
|
25
|
+
has_many :element_hashes, interface: ElementHash
|
26
|
+
|
27
|
+
def use(name)
|
28
|
+
self.modal = name
|
29
|
+
end
|
30
|
+
|
31
|
+
def get(type, name)
|
32
|
+
return modals[modal].get(type, name) if modal
|
33
|
+
|
34
|
+
case type
|
35
|
+
when :element
|
36
|
+
return elements[name].load
|
37
|
+
when :element_array
|
38
|
+
return element_arrays[name].load
|
39
|
+
when :element_hash
|
40
|
+
return element_hashes[name].load
|
41
|
+
else
|
42
|
+
raise AutomationObject::State::UndefinedLoadTypeError
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Whether or not modal is active
|
47
|
+
# @return [Boolean]
|
48
|
+
attr_accessor :active
|
49
|
+
|
50
|
+
undef :active if defined? :active
|
51
|
+
# @return [Boolean] screen is active or not
|
52
|
+
def active
|
53
|
+
@active ||= false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../error'
|
3
|
+
|
4
|
+
require_relative '_base'
|
5
|
+
require_relative 'screen'
|
6
|
+
|
7
|
+
require_relative 'helpers/window_manager'
|
8
|
+
|
9
|
+
module AutomationObject
|
10
|
+
module State
|
11
|
+
module Composite
|
12
|
+
# Top composite for managing state
|
13
|
+
class Top < Base
|
14
|
+
include WindowManager
|
15
|
+
|
16
|
+
# Children for this composite
|
17
|
+
has_many :screens, interface: Screen
|
18
|
+
|
19
|
+
def initialize(*args)
|
20
|
+
super(*args)
|
21
|
+
|
22
|
+
driver.get(blue_prints.base_url) if blue_prints.base_url
|
23
|
+
new_window(initial_screen)
|
24
|
+
end
|
25
|
+
|
26
|
+
def current_screen
|
27
|
+
screens[window.name]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get the initial screen
|
31
|
+
# @raise [AutomationObject::State::NoInitialScreenError] if no initial screen
|
32
|
+
# @return [Symbol] screen name
|
33
|
+
def initial_screen
|
34
|
+
# If default screen then check if its live and set it
|
35
|
+
if blue_prints.default_screen
|
36
|
+
default_name = blue_prints.default_screen
|
37
|
+
return default_name if screens[default_name].load.live? != false
|
38
|
+
|
39
|
+
raise AutomationObject::State::NoInitialScreenError
|
40
|
+
end
|
41
|
+
|
42
|
+
screens.each do |screen_name, screen|
|
43
|
+
return screen_name if screen.load.live?
|
44
|
+
end
|
45
|
+
|
46
|
+
raise AutomationObject::State::NoInitialScreenError
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,14 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module AutomationObject
|
2
3
|
module State
|
3
|
-
|
4
|
+
# Cannot navigate back error
|
5
|
+
class CannotNavigateBack < StandardError
|
6
|
+
def initialize(message = 'Cannot navigate backwards in history')
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Cannot navigate forward error
|
12
|
+
class CannotNavigateForward < StandardError
|
13
|
+
def initialize(message = 'Cannot navigate forwards in history')
|
14
|
+
super
|
15
|
+
end
|
4
16
|
end
|
5
17
|
|
18
|
+
# More than one expected new windows
|
19
|
+
class UnexpectedExtraWindowError < StandardError
|
20
|
+
def initialize(message = 'Expecting only 1 extra window')
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Undefined load type called on the State object
|
26
|
+
class UndefinedLoadTypeError < StandardError
|
27
|
+
end
|
28
|
+
|
29
|
+
# No initial screen to start from
|
6
30
|
class NoInitialScreenError < StandardError
|
7
31
|
def initialize(message = 'No initial screen to be set to')
|
8
32
|
super
|
9
33
|
end
|
10
34
|
end
|
11
35
|
|
36
|
+
# Screen is not currently active
|
12
37
|
class ScreenNotActiveError < StandardError
|
13
38
|
def initialize(screen)
|
14
39
|
message = "#{screen} is not currently active"
|
@@ -16,9 +41,23 @@ module AutomationObject
|
|
16
41
|
end
|
17
42
|
end
|
18
43
|
|
19
|
-
|
20
|
-
class
|
21
|
-
|
22
|
-
|
44
|
+
# Modal isn't active error
|
45
|
+
class ModalNotActiveError < StandardError
|
46
|
+
end
|
47
|
+
|
48
|
+
# Modal parent error
|
49
|
+
class ModalParentExpected < StandardError
|
50
|
+
end
|
51
|
+
|
52
|
+
# Screen parent error
|
53
|
+
class ScreenParentExpected < StandardError
|
54
|
+
end
|
55
|
+
|
56
|
+
# More than one screen created error
|
57
|
+
class MoreThenOneScreenCreated < StandardError
|
58
|
+
end
|
59
|
+
|
60
|
+
class NoActiveWindows < StandardError
|
61
|
+
end
|
23
62
|
end
|
24
|
-
end
|
63
|
+
end
|
@@ -1,38 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'error'
|
2
3
|
|
4
|
+
require_relative 'composite/top'
|
5
|
+
|
3
6
|
module AutomationObject
|
4
7
|
module State
|
5
|
-
#
|
8
|
+
# Session manages the DSL state
|
6
9
|
class Session
|
7
|
-
|
10
|
+
# @return [AutomationObject::Driver::Driver]
|
11
|
+
attr_accessor :driver
|
12
|
+
|
13
|
+
# @return [AutomationObject::BluePrint::Composite::Top]
|
14
|
+
attr_accessor :blue_prints
|
8
15
|
|
9
|
-
|
10
|
-
|
11
|
-
self.composite = args.fetch :composite
|
16
|
+
# @return [AutomationObject::State::Composite::Top]
|
17
|
+
attr_accessor :composite
|
12
18
|
|
13
|
-
|
19
|
+
# @param [AutomationObject::Driver::Driver] driver
|
20
|
+
# @param [AutomationObject::BluePrint::Composite::Top] blue_prints
|
21
|
+
def initialize(driver, blue_prints)
|
22
|
+
self.driver = driver
|
23
|
+
self.composite = Composite::Top.new(self, driver, blue_prints)
|
14
24
|
end
|
15
25
|
|
16
26
|
def load(type, name)
|
17
27
|
case type
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
raise AutomationObject::State::ModalNotActiveError.new(name)
|
27
|
-
end
|
28
|
-
|
29
|
-
self.composite.use_modal(name)
|
30
|
-
when :element, :element_array, :element_hash
|
31
|
-
return self.composite.get_object(type, name)
|
32
|
-
else
|
33
|
-
raise AutomationObject::State::UndefinedLoadTypeError.new
|
28
|
+
when :screen
|
29
|
+
composite.use(name)
|
30
|
+
when :modal
|
31
|
+
composite.current_screen.use(name)
|
32
|
+
when :element, :element_array, :element_hash
|
33
|
+
return composite.current_screen.get(type, name)
|
34
|
+
else
|
35
|
+
raise AutomationObject::State::UndefinedLoadTypeError
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
38
|
-
end
|
40
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module AutomationObject
|
2
|
-
#Require step definitons at run-time, only when running in a Cucumber context
|
3
|
+
# Require step definitons at run-time, only when running in a Cucumber context
|
3
4
|
module StepDefinitions
|
4
|
-
|
5
|
+
module_function
|
5
6
|
|
6
7
|
def load
|
8
|
+
# Using minitest to run assertions
|
7
9
|
require 'minitest/autorun'
|
8
10
|
require 'minitest/unit'
|
9
11
|
require 'minitest-bonus-assertions'
|
@@ -11,4 +13,4 @@ module AutomationObject
|
|
11
13
|
Dir[File.dirname(__FILE__) + '/step_definitions/**/*.rb'].each { |file| require file }
|
12
14
|
end
|
13
15
|
end
|
14
|
-
end
|
16
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'support/parse'
|
3
|
+
|
4
|
+
# Description: Provides step definitions related to elements
|
5
|
+
|
6
|
+
# For: Calling an element method
|
7
|
+
# Examples:
|
8
|
+
# - I click on the "home_screen" "about_button" element
|
9
|
+
# - I hover over the "home_screen" "test_link" element
|
10
|
+
# - I tap on "home_screen" "logo_button" element
|
11
|
+
When(/^I (\w+|%\{[\w\d]+\}) ?(?: on| over)? (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
|
12
|
+
method, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
13
|
+
AutomationObject::Framework.get.send(screen).send(element).send(method)
|
14
|
+
end
|
15
|
+
|
16
|
+
# For: Typing into element field
|
17
|
+
# Examples:
|
18
|
+
# - I type "blah" into the "home_screen" "text_field" element
|
19
|
+
# - I type "test" in the "home_screen" "text_field" element
|
20
|
+
# - I type "blah" in "home_screen" "text_field" element
|
21
|
+
When(/^I type "([\w\s]+|%\{[\w\d]+\})" in(?:to)? (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
|
22
|
+
text, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
23
|
+
AutomationObject::Framework.get.send(screen).send(element).send_keys(text)
|
24
|
+
end
|
25
|
+
|
26
|
+
# For: Scrolling element into focus
|
27
|
+
# Examples:
|
28
|
+
# - I scroll to the "home_screen" "logo_button" element
|
29
|
+
# - I focus to the "home_screen" "logo_button" element
|
30
|
+
# - I scroll to "home_screen" "logo_button" element
|
31
|
+
When(/^I (?:scroll |focus )to (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
|
32
|
+
screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
33
|
+
AutomationObject::Framework.get.send(screen).send(element).scroll_into_view
|
34
|
+
end
|
35
|
+
|
36
|
+
# For: Saving value from element for use later
|
37
|
+
# Examples:
|
38
|
+
# - I save "text" as "unique_value" from the "home_screen" "logo_button" element
|
39
|
+
# - I save "id" as "unique_value" from "home_screen" "logo_button" element
|
40
|
+
When(/^I save "(\w+|%\{[\w\d]+\})" as "([\w\d]+)" from (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
|
41
|
+
method, key, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
42
|
+
# Save value from called method/property
|
43
|
+
value = AutomationObject::Framework.get.send(screen).send(element).send(method)
|
44
|
+
AutomationObject::StepDefinitions::Cache.set(key, value)
|
45
|
+
end
|
46
|
+
|
47
|
+
# For: Testing if the element exists or not
|
48
|
+
# Examples:
|
49
|
+
# - the "home_screen" "title" element should exist
|
50
|
+
# - the "home_screen" "title" element shouldn't exist
|
51
|
+
# - "home_screen" "title" element should not exist
|
52
|
+
Then(/^(?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element should ?(n't |not )?exist$/) do |*args|
|
53
|
+
screen, element, negative = AutomationObject::StepDefinitions::Parse.new(args).get
|
54
|
+
|
55
|
+
exists = AutomationObject::Framework.get.send(screen).send(element).exists?
|
56
|
+
if negative
|
57
|
+
assert_equal false, exists
|
58
|
+
else
|
59
|
+
assert_equal true, exists
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# For: Testing if the element method value equals a given value
|
64
|
+
# Examples:
|
65
|
+
# - the "home_screen" "title" element "text" should equal "Home"
|
66
|
+
# - "home_screen" "title" element "text" should not equal "About"
|
67
|
+
# - the "home_screen" "title" element "text" shouldn't equal "%{saved_value}"
|
68
|
+
Then(/^(?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element "(\w+|%\{[\w\d]+\})" should ?(n't |not )?equal "(\w+|%\{[\w\d]+\})"$/) do |*args|
|
69
|
+
screen, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
70
|
+
|
71
|
+
actual_value = AutomationObject::Framework.get.send(screen).send(element).send(method)
|
72
|
+
if negative
|
73
|
+
refute_equal expected_value, actual_value
|
74
|
+
else
|
75
|
+
assert_equal expected_value, actual_value
|
76
|
+
end
|
77
|
+
end
|