automation_object 0.7.6 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/automation_object/blue_print.rb +1 -0
  3. data/lib/automation_object/blue_print/composite/{automatic_onload_modal.rb → automatic_modal_change.rb} +3 -4
  4. data/lib/automation_object/blue_print/composite/base.rb +1 -0
  5. data/lib/automation_object/blue_print/composite/custom_method.rb +2 -3
  6. data/lib/automation_object/blue_print/composite/element.rb +2 -3
  7. data/lib/automation_object/blue_print/composite/element_array.rb +2 -3
  8. data/lib/automation_object/blue_print/composite/element_hash.rb +2 -3
  9. data/lib/automation_object/blue_print/composite/helpers/container_helper.rb +75 -0
  10. data/lib/automation_object/blue_print/composite/helpers/element_helper.rb +30 -1
  11. data/lib/automation_object/blue_print/composite/helpers/multiple_elements_helper.rb +1 -0
  12. data/lib/automation_object/blue_print/composite/hook.rb +18 -6
  13. data/lib/automation_object/blue_print/composite/hook_action.rb +3 -4
  14. data/lib/automation_object/blue_print/composite/hook_element_requirements.rb +3 -4
  15. data/lib/automation_object/blue_print/composite/modal.rb +12 -9
  16. data/lib/automation_object/blue_print/composite/screen.rb +17 -14
  17. data/lib/automation_object/blue_print/composite/top.rb +3 -2
  18. data/lib/automation_object/blue_print/composite/view.rb +8 -7
  19. data/lib/automation_object/blue_print/hash_adapter.rb +1 -0
  20. data/lib/automation_object/blue_print/hash_adapter/{automatic_onload_modal.rb → automatic_modal_change.rb} +3 -2
  21. data/lib/automation_object/blue_print/hash_adapter/composite.rb +1 -0
  22. data/lib/automation_object/blue_print/hash_adapter/custom_method.rb +1 -0
  23. data/lib/automation_object/blue_print/hash_adapter/element.rb +2 -0
  24. data/lib/automation_object/blue_print/hash_adapter/element_array.rb +1 -0
  25. data/lib/automation_object/blue_print/hash_adapter/element_hash.rb +1 -0
  26. data/lib/automation_object/blue_print/hash_adapter/helpers/element_helper.rb +8 -2
  27. data/lib/automation_object/blue_print/hash_adapter/helpers/multiple_elements_helper.rb +1 -0
  28. data/lib/automation_object/blue_print/hash_adapter/helpers/validation_error.rb +2 -1
  29. data/lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb +1 -0
  30. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate.rb +1 -0
  31. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_allowed_keys.rb +1 -0
  32. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_element_presence_of.rb +1 -0
  33. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_instance_of.rb +1 -0
  34. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb +1 -0
  35. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_presence_of.rb +1 -0
  36. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_screen_presence_of.rb +1 -0
  37. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_presence_of.rb +1 -0
  38. data/lib/automation_object/blue_print/hash_adapter/hook.rb +2 -1
  39. data/lib/automation_object/blue_print/hash_adapter/hook_action.rb +4 -3
  40. data/lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb +2 -1
  41. data/lib/automation_object/blue_print/hash_adapter/modal.rb +2 -1
  42. data/lib/automation_object/blue_print/hash_adapter/screen.rb +14 -13
  43. data/lib/automation_object/blue_print/hash_adapter/top.rb +3 -2
  44. data/lib/automation_object/blue_print/hash_adapter/view.rb +12 -11
  45. data/lib/automation_object/blue_print/yaml_adapter.rb +1 -0
  46. data/lib/automation_object/driver.rb +1 -0
  47. data/lib/automation_object/driver/appium_adapter/driver.rb +2 -1
  48. data/lib/automation_object/driver/appium_adapter/element.rb +1 -0
  49. data/lib/automation_object/driver/base.rb +1 -0
  50. data/lib/automation_object/driver/common_selenium/driver.rb +1 -0
  51. data/lib/automation_object/driver/common_selenium/element.rb +1 -0
  52. data/lib/automation_object/driver/common_selenium/element_geometry.rb +1 -0
  53. data/lib/automation_object/driver/driver.rb +1 -0
  54. data/lib/automation_object/driver/element.rb +1 -0
  55. data/lib/automation_object/driver/nokogiri_adapter/driver.rb +5 -8
  56. data/lib/automation_object/driver/nokogiri_adapter/element.rb +9 -14
  57. data/lib/automation_object/driver/nokogiri_adapter/error.rb +1 -0
  58. data/lib/automation_object/driver/nokogiri_adapter/form.rb +1 -0
  59. data/lib/automation_object/driver/nokogiri_adapter/request.rb +1 -0
  60. data/lib/automation_object/driver/nokogiri_adapter/session.rb +1 -0
  61. data/lib/automation_object/driver/nokogiri_adapter/window.rb +1 -0
  62. data/lib/automation_object/driver/selenium_adapter/driver.rb +1 -0
  63. data/lib/automation_object/driver/selenium_adapter/element.rb +1 -0
  64. data/lib/automation_object/dsl.rb +4 -2
  65. data/lib/automation_object/dsl/_base.rb +11 -1
  66. data/lib/automation_object/dsl/_error.rb +71 -0
  67. data/lib/automation_object/dsl/_proxy.rb +1 -0
  68. data/lib/automation_object/dsl/element.rb +2 -2
  69. data/lib/automation_object/dsl/element_array.rb +2 -2
  70. data/lib/automation_object/dsl/element_hash.rb +2 -2
  71. data/lib/automation_object/dsl/modal.rb +47 -2
  72. data/lib/automation_object/dsl/screen.rb +67 -3
  73. data/lib/automation_object/dsl/top.rb +19 -0
  74. data/lib/automation_object/framework.rb +18 -1
  75. data/lib/automation_object/helpers/composite.rb +3 -1
  76. data/lib/automation_object/helpers/composite_hook.rb +1 -0
  77. data/lib/automation_object/helpers/file.rb +1 -0
  78. data/lib/automation_object/helpers/hash.rb +1 -0
  79. data/lib/automation_object/helpers/kernel.rb +1 -0
  80. data/lib/automation_object/helpers/reflection.rb +1 -0
  81. data/lib/automation_object/helpers/string.rb +1 -0
  82. data/lib/automation_object/proxy/mutex_proxy.rb +1 -0
  83. data/lib/automation_object/proxy/proxy.rb +1 -0
  84. data/lib/automation_object/proxy/throttle_proxy.rb +2 -1
  85. data/lib/automation_object/state.rb +5 -1
  86. data/lib/automation_object/state/_base.rb +2 -1
  87. data/lib/automation_object/state/_common_element.rb +5 -0
  88. data/lib/automation_object/state/_error.rb +1 -0
  89. data/lib/automation_object/state/automatic_modal_change.rb +13 -0
  90. data/lib/automation_object/state/automatic_screen_changes.rb +13 -0
  91. data/lib/automation_object/state/element.rb +2 -1
  92. data/lib/automation_object/state/element_array.rb +2 -1
  93. data/lib/automation_object/state/element_hash.rb +2 -1
  94. data/lib/automation_object/state/element_proxy.rb +1 -0
  95. data/lib/automation_object/state/helpers/automatic_routing.rb +96 -0
  96. data/lib/automation_object/state/helpers/container_helper.rb +46 -0
  97. data/lib/automation_object/state/hook.rb +1 -0
  98. data/lib/automation_object/state/hook_action.rb +1 -0
  99. data/lib/automation_object/state/hook_actions/action_loop.rb +1 -0
  100. data/lib/automation_object/state/hook_actions/change_screen.rb +1 -0
  101. data/lib/automation_object/state/hook_actions/change_to_previous_screen.rb +1 -0
  102. data/lib/automation_object/state/hook_actions/close_modal.rb +1 -0
  103. data/lib/automation_object/state/hook_actions/close_screen.rb +1 -0
  104. data/lib/automation_object/state/hook_actions/element_requirement.rb +1 -0
  105. data/lib/automation_object/state/hook_actions/new_screen.rb +1 -0
  106. data/lib/automation_object/state/hook_actions/possible_screen_changes.rb +1 -0
  107. data/lib/automation_object/state/hook_actions/reset_screen.rb +1 -0
  108. data/lib/automation_object/state/hook_actions/show_modal.rb +1 -0
  109. data/lib/automation_object/state/hook_actions/sleep.rb +1 -0
  110. data/lib/automation_object/state/hook_actions/wait_for_elements.rb +1 -0
  111. data/lib/automation_object/state/modal.rb +5 -14
  112. data/lib/automation_object/state/screen.rb +33 -19
  113. data/lib/automation_object/state/top.rb +17 -2
  114. data/lib/automation_object/step_definitions.rb +3 -4
  115. data/lib/automation_object/step_definitions/element.rb +22 -23
  116. data/lib/automation_object/step_definitions/element_array.rb +26 -27
  117. data/lib/automation_object/step_definitions/element_hash.rb +26 -27
  118. data/lib/automation_object/step_definitions/modal.rb +31 -0
  119. data/lib/automation_object/step_definitions/screen.rb +22 -10
  120. data/lib/automation_object/step_definitions/support/cache.rb +5 -2
  121. data/lib/automation_object/step_definitions/support/element_array.rb +1 -1
  122. data/lib/automation_object/step_definitions/support/parse.rb +1 -1
  123. data/lib/automation_object/version.rb +2 -1
  124. metadata +59 -39
  125. data/lib/automation_object/step_definitions/support/minitest.rb +0 -10
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AutomationObject
4
+ module State
5
+ module ContainerHelper
6
+ # Whether or not modal is active
7
+ attr_accessor :active
8
+
9
+ # @return [Boolean] screen is active or not
10
+ def active?
11
+ @active ||= false
12
+ end
13
+
14
+ # Automatically find a way to go to this screen
15
+ # @return [Boolean]
16
+ def go
17
+ if active?
18
+ utilize
19
+ return true
20
+ end
21
+
22
+ AutomaticRouting.new(top, name).route
23
+ end
24
+
25
+ # @return [Array<Symbol>]
26
+ def changes
27
+ blue_prints.changes
28
+ end
29
+
30
+ # @param name [Symbol] name of container you want to go to
31
+ # @return [AutomationObject::State::Element]
32
+ def element_to_container(name)
33
+ element_name, element_type = blue_prints.element_to_container(name)
34
+ return unless element_name || element_type
35
+
36
+ send(element_type)[element_name]
37
+ end
38
+
39
+ def reset
40
+ elements.values.map(&:reset)
41
+ element_arrays.values.map(&:reset)
42
+ element_hashes.values.map(&:reset)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '_base'
3
4
 
4
5
  require_relative 'hook_action'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '_base'
3
4
 
4
5
  require_relative 'hook_actions/change_screen'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module AutomationObject
3
4
  module State
4
5
  # Composite action loop base class
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
  require_relative '../_error'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
  require_relative '../_error'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
  require_relative '../_error'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'action_loop'
3
4
 
4
5
  module AutomationObject
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '_base'
3
4
  require_relative '_error'
4
5
 
@@ -6,10 +7,14 @@ require_relative 'element'
6
7
  require_relative 'element_array'
7
8
  require_relative 'element_hash'
8
9
 
10
+ require_relative 'helpers/container_helper'
11
+
9
12
  module AutomationObject
10
13
  module State
11
14
  # Modal composite for managing state
12
15
  class Modal < Base
16
+ include ContainerHelper
17
+
13
18
  has_one :load, interface: Hook
14
19
 
15
20
  has_many :elements, interface: Element
@@ -20,14 +25,6 @@ module AutomationObject
20
25
  raise ModalNotActiveError, name unless active?
21
26
  end
22
27
 
23
- # Whether or not modal is active
24
- attr_accessor :active
25
-
26
- # @return [Boolean] screen is active or not
27
- def active?
28
- @active ||= false
29
- end
30
-
31
28
  def activate
32
29
  @active = true
33
30
  end
@@ -36,12 +33,6 @@ module AutomationObject
36
33
  @active = false
37
34
  reset
38
35
  end
39
-
40
- def reset
41
- elements.values.map(&:reset)
42
- element_arrays.values.map(&:reset)
43
- element_hashes.values.map(&:reset)
44
- end
45
36
  end
46
37
  end
47
38
  end
@@ -1,70 +1,84 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '_base'
3
4
  require_relative '_error'
4
5
 
6
+ require_relative 'automatic_modal_change'
7
+ require_relative 'automatic_screen_changes'
5
8
  require_relative 'modal'
6
9
  require_relative 'hook'
7
10
  require_relative 'element'
8
11
  require_relative 'element_array'
9
12
  require_relative 'element_hash'
10
13
 
14
+ require_relative 'helpers/automatic_routing'
15
+ require_relative 'helpers/container_helper'
16
+
11
17
  module AutomationObject
12
18
  module State
13
19
  # Screen composite for managing state
14
20
  class Screen < Base
21
+ include ContainerHelper
22
+
15
23
  attr_accessor :modal, :window_handle, :previous_screen_name
16
24
 
25
+ # @return [AutomaticScreenChanges]
26
+ attr_accessor :automatic_screen_changes
27
+
17
28
  has_one :load, interface: Hook
18
29
 
19
30
  # Children for this composite
31
+ # has_many :automatic_modal_changes, interface: AutomaticModalChange
20
32
  has_many :modals, interface: Modal
21
33
 
22
34
  has_many :elements, interface: Element
23
35
  has_many :element_arrays, interface: ElementArray
24
36
  has_many :element_hashes, interface: ElementHash
25
37
 
26
- # Whether or not modal is active
27
- attr_accessor :active
28
-
29
- # @return [Boolean] screen is active or not
30
- def active?
31
- @active ||= false
32
- end
33
-
38
+ # @return [void]
34
39
  def activate
35
40
  @active = true
36
41
  self.window_handle = driver.window_handle
42
+
43
+ return if blue_prints.automatic_screen_changes.empty?
44
+
45
+ # Add automatic screen change to a new thread and test for screen changes
46
+ self.automatic_screen_changes = AutomaticScreenChanges.new(driver,
47
+ blue_prints.automatic_screen_changes,
48
+ :automatic_screen_changes,
49
+ self,
50
+ location + '[automatic_screen_changes]')
51
+ automatic_screen_changes.activate
37
52
  end
38
53
 
54
+ # @return [void]
39
55
  def deactivate
56
+ automatic_screen_changes&.deactivate
57
+
58
+ self.automatic_screen_changes, self.window_handle = nil
40
59
  @active = false
41
- self.window_handle = nil
60
+
42
61
  modals.values.map(&:deactivate)
43
62
  reset
44
63
  end
45
64
 
65
+ # @return [void]
46
66
  def utilize
47
67
  raise ScreenNotActiveError, name unless active?
48
- driver.window_handle = window_handle if window_handle != driver.window_handle
68
+ driver.window_handle = window_handle
49
69
  end
50
70
 
71
+ # @return [void]
51
72
  def close
52
- raise ScreenNotActiveError, name unless active?
53
-
54
- driver.window_handle = window_handle if window_handle != driver.window_handle
73
+ utilize
55
74
  driver.close
75
+ deactivate
56
76
  end
57
77
 
58
78
  # @return [Boolean]
59
79
  def closed?
60
80
  !driver.window_handles.include?(window_handle)
61
81
  end
62
-
63
- def reset
64
- elements.values.map(&:reset)
65
- element_arrays.values.map(&:reset)
66
- element_hashes.values.map(&:reset)
67
- end
68
82
  end
69
83
  end
70
84
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '_base'
3
4
  require_relative '_error'
4
5
 
@@ -9,11 +10,20 @@ module AutomationObject
9
10
  # Top composite for managing state
10
11
  class Top < Base
11
12
  # Children for this composite
13
+ # @return [Hash<Screen>]
12
14
  has_many :screens, interface: Screen
13
15
 
14
- def initialize(*args)
15
- super(*args)
16
+ # @param driver [AutomationObject::Driver] driver
17
+ # @param blue_prints [AutomationObject::BluePrint::Composite::Base] blue print composite
18
+ # @param name [Symbol] name of composite element
19
+ # @param parent [Object, nil] parent composite object
20
+ # @param location [String] string location for error/debugging purposes
21
+ def initialize(driver, blue_prints, name = :top, parent = nil, location = 'top')
22
+ super
23
+ end
16
24
 
25
+ # @return [Void]
26
+ def start
17
27
  driver.get(blue_prints.base_url) if blue_prints.base_url
18
28
  set_initial_screen
19
29
  end
@@ -38,6 +48,11 @@ module AutomationObject
38
48
 
39
49
  raise AutomationObject::State::NoInitialScreenError
40
50
  end
51
+
52
+ # @return [Hash<Screen>] active screens
53
+ def active_screens
54
+ screens.select { |_key, value| value.active? }
55
+ end
41
56
  end
42
57
  end
43
58
  end
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module AutomationObject
3
4
  # Require step definitons at run-time, only when running in a Cucumber context
4
5
  module StepDefinitions
5
6
  module_function
6
7
 
7
8
  def load
8
- # Using minitest to run assertions
9
- require 'minitest/autorun'
10
- require 'minitest/unit'
11
- require 'minitest-bonus-assertions'
9
+ # Using rspec to run assertions
10
+ require 'rspec/expectations'
12
11
 
13
12
  Dir[File.dirname(__FILE__) + '/step_definitions/**/*.rb'].each { |file| require file }
14
13
  end
@@ -1,78 +1,77 @@
1
1
  # frozen_string_literal: true
2
2
  require_relative 'support/parse'
3
- require_relative 'support/minitest'
4
3
 
5
4
  # Description: Provides step definitions related to elements
6
5
 
7
- # For: Calling an element method
6
+ # Call an element method
8
7
  # Examples:
9
8
  # - I click on the "home_screen" "about_button" element
10
9
  # - I hover over the "home_screen" "test_link" element
11
10
  # - I tap on "home_screen" "logo_button" element
12
- When(/^I (\w+|%\{[\w\d]+\}) ?(?: on| over)? (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
11
+ When(%r(^I (\w+|%\{\w+\}) ?(?: on| over)? (?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element$)) do |*args|
13
12
  method, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
14
- AutomationObject::Framework.get.send(screen).send(element).send(method)
13
+ AutomationObject::Framework.get.screen(screen).element(element).send(method)
15
14
  end
16
15
 
17
- # For: Typing into element field
16
+ # For: Type into element field
18
17
  # Examples:
19
18
  # - I type "blah" into the "home_screen" "text_field" element
20
19
  # - I type "test" in the "home_screen" "text_field" element
21
20
  # - I type "blah" in "home_screen" "text_field" element
22
- When(/^I type "([^"]+|%\{[\w\d]+\})" in(?:to)? (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
21
+ When(%r(^I type "([^"]+|%\{\w+\})" in(?:to)? (?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element$)) do |*args|
23
22
  text, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
24
- AutomationObject::Framework.get.send(screen).send(element).send_keys(text)
23
+ AutomationObject::Framework.get.screen(screen).element(element).send_keys(text)
25
24
  end
26
25
 
27
- # For: Scrolling element into focus
26
+ # For: Scroll element into focus
28
27
  # Examples:
29
28
  # - I scroll to the "home_screen" "logo_button" element
30
29
  # - I focus to the "home_screen" "logo_button" element
31
30
  # - I scroll to "home_screen" "logo_button" element
32
- When(/^I (?:scroll |focus )to (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
31
+ When(%r(^I (?:scroll |focus )to (?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element$)) do |*args|
33
32
  screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
34
- AutomationObject::Framework.get.send(screen).send(element).scroll_into_view
33
+ AutomationObject::Framework.get.screen(screen).element(element).scroll_into_view
35
34
  end
36
35
 
37
- # For: Saving value from element for use later
36
+ # For: Save value from element for use later
38
37
  # Examples:
39
38
  # - I save "text" as "unique_value" from the "home_screen" "logo_button" element
40
39
  # - I save "id" as "unique_value" from "home_screen" "logo_button" element
41
- When(/^I save "(\w+|%\{[\w\d]+\})" as "([\w\d]+)" from (?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element$/) do |*args|
40
+ When(%r(^I save "(\w+|%\{\w+\})" as "(\w+)" from (?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element$)) do |*args|
42
41
  method, key, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
43
42
  # Save value from called method/property
44
- value = AutomationObject::Framework.get.send(screen).send(element).send(method)
43
+ value = AutomationObject::Framework.get.screen(screen).element(element).send(method)
45
44
  AutomationObject::StepDefinitions::Cache.set(key, value)
46
45
  end
47
46
 
48
- # For: Testing if the element exists or not
47
+ # For: Test if the element exists or not
49
48
  # Examples:
50
49
  # - the "home_screen" "title" element should exist
51
50
  # - the "home_screen" "title" element shouldn't exist
52
51
  # - "home_screen" "title" element should not exist
53
- Then(/^(?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element should ?(n't |not )?exist$/) do |*args|
52
+ Then(%r(^(?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element should ?(n't |not )?exist$)) do |*args|
54
53
  screen, element, negative = AutomationObject::StepDefinitions::Parse.new(args).get
55
54
 
56
- exists = AutomationObject::Framework.get.send(screen).send(element).exists?
55
+ exists = AutomationObject::Framework.get.screen(screen).element(element).exists?
57
56
  if negative
58
- assert_equal false, exists
57
+ expect(exists).to eq(false)
59
58
  else
60
- assert_equal true, exists
59
+ expect(exists).to eq(true)
61
60
  end
62
61
  end
63
62
 
64
- # For: Testing if the element method value equals a given value
63
+ # For: Test if the element method value equals a given value
65
64
  # Examples:
66
65
  # - the "home_screen" "title" element "text" should equal "Home"
67
66
  # - "home_screen" "title" element "text" should not equal "About"
68
67
  # - the "home_screen" "title" element "text" shouldn't equal "%{saved_value}"
69
- Then(/^(?:the )?"(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element "(\w+|%\{[\w\d]+\})" should ?(n't |not )?equal "(\w+|%\{[\w\d]+\})"$/) do |*args|
68
+ Then(%r(^(?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element "(\w+|%\{\w+\})" should ?(n't |not )?equal "(\w+|%\{\w+\})"$)) do |*args|
70
69
  screen, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
71
70
 
72
- actual_value = AutomationObject::Framework.get.send(screen).send(element).send(method)
71
+ actual_value = AutomationObject::Framework.get.screen(screen).element(element).send(method)
73
72
  if negative
74
- refute_equal expected_value, actual_value
73
+ expect(expected_value).not_to eq(actual_value)
75
74
  else
76
- assert_equal expected_value, actual_value
75
+ expect(expected_value).to eq(actual_value)
77
76
  end
78
77
  end