automation_object 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,17 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  require_relative 'support/parse'
3
3
  require_relative 'support/element_array'
4
- require_relative 'support/minitest'
5
4
 
6
5
  # Description: Provides step definitions related to element arrays
7
6
 
8
- # For: Calling an element array method
7
+ # For: Call an element array method
9
8
  # Examples:
10
9
  # - I click on the first "home_screen" "about_button" element array
11
10
  # - I hover over all "home_screen" "about_button" element array
12
11
  # - I click on 0..9 "home_screen" "about_button" element array
13
12
  # - I click on a random "home_screen" "about_button" element array
14
- When(%r(^I (\w+|%\{[\w\d]+\})?(?: on| over)?(?: the| a)? (%\{[\w\d]+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element array$/)) do |*args|
13
+ When(%r(^I (\w+|%\{\w+\})?(?: on| over)?(?: the| a)? (%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element array$)) do |*args|
15
14
  method, key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
16
15
 
17
16
  AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
@@ -21,10 +20,10 @@ When(%r(^I (\w+|%\{[\w\d]+\})?(?: on| over)?(?: the| a)? (%\{[\w\d]+\}|all|rando
21
20
  end
22
21
  end
23
22
 
24
- # For: Typing into element array field
23
+ # For: Type into element array field
25
24
  # Examples:
26
25
  # - I type "blah" into the first "home_screen" "text_field" element array
27
- When(%r(^I type "([\w\s]+|%\{[\w\d]+\})" in(?:to| to)? (?:the )?(%\{[\w\d]+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element array$)) do |*args|
26
+ When(%r(^I type "([\w\s]+|%\{\w+\})" in(?:to| to)? (?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element array$)) do |*args|
28
27
  text, key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
29
28
 
30
29
  AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
@@ -34,10 +33,10 @@ When(%r(^I type "([\w\s]+|%\{[\w\d]+\})" in(?:to| to)? (?:the )?(%\{[\w\d]+\}|ra
34
33
  end
35
34
  end
36
35
 
37
- # For: Scrolling element array item(s) into focus
36
+ # For: Scroll element array item(s) into focus
38
37
  # Examples:
39
38
  # - I scroll to the first "home_screen" "logo_button" element array
40
- When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{[\w\d]+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element array$)) do |*args|
39
+ When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element array$)) do |*args|
41
40
  key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
42
41
 
43
42
  AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
@@ -45,10 +44,10 @@ When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{[\w\d]+\}|all|random|l
45
44
  )
46
45
  end
47
46
 
48
- # For: Saving value from element array for use later
47
+ # For: Save value from element array for use later
49
48
  # Examples:
50
49
  # - I save "text" as "unique_value" from the first "home_screen" "logo_button" element array
51
- When(%r(^I save "(\w+|%\{[\w\d]+\})" as "([\w\d]+)" from (?:the )?(%\{[\w\d]+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element array$)) do |*args|
50
+ When(%r(^I save "(\w+|%\{\w+\})" as "(\w+)" from (?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element array$)) do |*args|
52
51
  method, value_key, key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
53
52
 
54
53
  AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
@@ -59,44 +58,44 @@ When(%r(^I save "(\w+|%\{[\w\d]+\})" as "([\w\d]+)" from (?:the )?(%\{[\w\d]+\}|
59
58
  end
60
59
  end
61
60
 
62
- # For: Testing the element arrays size
61
+ # For: Test the element arrays length
63
62
  # Examples:
64
63
  # - the "home_screen" "title" element array should be greater than 0
65
- Then(%r(^(?:the )?"([\w\d]+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element array should(n't|not)? (?:be )?(larger th[ae]n|greater th[ae]n|less th[ae]n|smaller th[ae]n|equals?) (?:to )?(\d+)$)) do |*args|
64
+ Then(%r(^(?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element array should(n't|not)? (?:be )?(larger th[ae]n|greater th[ae]n|less th[ae]n|smaller th[ae]n|equals?) (?:to )?(\d+)$)) do |*args|
66
65
  screen, element, negative, comparison, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
67
66
 
68
- element_array = AutomationObject::Framework.get.send(screen).send(element)
67
+ element_array = AutomationObject::Framework.get.screen(screen).element_array(element)
69
68
  assert element_array.is_a?(Array)
70
69
 
71
70
  if comparison =~ /larger th[ae]n|greater th[ae]n/
72
71
  if negative
73
- refute expected_value < element_array.length
72
+ expect(expected_value).to_not be < element_array.length
74
73
  else
75
- assert expected_value < element_array.length
74
+ expect(expected_value).to be < element_array.length
76
75
  end
77
76
  elsif comparison =~ /smaller th[ae]n|less th[ae]n/
78
77
  if negative
79
- refute expected_value > element_array.length
78
+ expect(expected_value).to_not be > element_array.length
80
79
  else
81
- assert expected_value > element_array.length
80
+ expect(expected_value).to be > element_array.length
82
81
  end
83
82
  elsif comparison =~ /equals?/
84
83
  if negative
85
- refute_equals expected_value, element_array.length
84
+ expect(expected_value).to_not eq(element_array.length)
86
85
  else
87
- assert_equals expected_value, element_array.length
86
+ expect(expected_value).to eq(element_array.length)
88
87
  end
89
88
  end
90
89
  end
91
90
 
92
- # For: Testing if the element method value equals a given value
91
+ # For: Test if the element method value equals a given value
93
92
  # Examples:
94
93
  # - the first "home_screen" "title" element array "text" should equal "Home"
95
94
  # - the last "home_screen" "title" element array "text" shouldn't equal "Home"
96
95
  # - the random "home_screen" "title" element array "text" should not equal "Home"
97
96
  # - the 0..9 "home_screen" "title" element array "text" should equal "Home"
98
97
  # - the all "home_screen" "title" element array "text" should not equal "Home"
99
- Then(%r(^(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element array "(\w+|%\{[\w\d]+\})" should?(n't| not)? equal "(\w+|%\{[\w\d]+\})"$)) do |*args|
98
+ Then(%r(^(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element array "(\w+|%\{\w+\})" should?(n't| not)? equal "(\w+|%\{\w+\})"$)) do |*args|
100
99
  key, low_range, high_range, screen, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
101
100
 
102
101
  AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
@@ -105,22 +104,22 @@ Then(%r(^(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d
105
104
  value = sub_element.send(method)
106
105
 
107
106
  if negative
108
- refute_equals expected_value, value
107
+ expect(expected_value).to_not eq(value)
109
108
  else
110
- assert_equals expected_value, value
109
+ expect(expected_value).to eq(value)
111
110
  end
112
111
  end
113
112
  end
114
113
 
115
- # For: Testing if the element arrays uniqueness
114
+ # For: Test if the element arrays is unique
116
115
  # Examples:
117
116
  # - the "home_screen" "title" element array "text" should be unique
118
117
  # - the "home_screen" "title" element array "text" should not be unique
119
118
  # - the "home_screen" "title" element array "text" shouldn't be unique
120
- Then(%r(^(?:the )?"([\w\d]+|%\{[\w\d]+\})" "([\w\d]+|%\{[\w\d]+\})" element array "([\w\d]+|%\{[\w\d]+\})" should(n't| not)? be unique$)) do |*args|
119
+ Then(%r(^(?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element array "(\w+|%\{\w+\})" should(n't| not)? be unique$)) do |*args|
121
120
  screen, element, method, negative = AutomationObject::StepDefinitions::Parse.new(args).get
122
121
 
123
- element_array = AutomationObject::Framework.get.send(screen).send(element)
122
+ element_array = AutomationObject::Framework.get.screen(screen).element_array(element)
124
123
  assert element_array.is_a?(Array)
125
124
 
126
125
  values = []
@@ -129,8 +128,8 @@ Then(%r(^(?:the )?"([\w\d]+|%\{[\w\d]+\})" "([\w\d]+|%\{[\w\d]+\})" element arra
129
128
  end
130
129
 
131
130
  if negative
132
- refute_equals values.uniq, values
131
+ expect(values.uniq).to_not eq(values)
133
132
  else
134
- assert_equals values.uniq, values
133
+ expect(values.uniq).to eq(values)
135
134
  end
136
135
  end
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
  require_relative 'support/parse'
3
3
  require_relative 'support/element_hash'
4
- require_relative 'support/minitest'
5
4
 
6
5
  # Description: Provides step definitions related to element hashes
7
6
 
8
- # For: Calling an element hash method
7
+ # For: Call an element hash method
9
8
  # Examples:
10
9
  # - I click on the first "home_screen" "about_button" element hash
11
- When(%r(^I (\w+|%\{[\w\d]+\})?(?: on| over)?(?: the| a)? (%\{[\w\d]+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element hash$)) do |*args|
10
+ When(%r(^I (\w+|%\{\w+\})?(?: on| over)?(?: the| a)? (%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element hash$)) do |*args|
12
11
  method, key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
13
12
 
14
13
  AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
@@ -18,10 +17,10 @@ When(%r(^I (\w+|%\{[\w\d]+\})?(?: on| over)?(?: the| a)? (%\{[\w\d]+\}|all|rando
18
17
  end
19
18
  end
20
19
 
21
- # For: Typing into element hash field
20
+ # For: Type into element hash field
22
21
  # Examples:
23
22
  # - I type "blah" into the first "home_screen" "text_field" element hash
24
- When(%r(^I type "([\w\s]+|%\{[\w\d]+\})" in(?:to| to)? (?:the )?(%\{[\w\d]+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element hash$)) do |*args|
23
+ When(%r(^I type "([\w\s]+|%\{\w+\})" in(?:to| to)? (?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element hash$)) do |*args|
25
24
  text, key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
26
25
 
27
26
  AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
@@ -31,10 +30,10 @@ When(%r(^I type "([\w\s]+|%\{[\w\d]+\})" in(?:to| to)? (?:the )?(%\{[\w\d]+\}|ra
31
30
  end
32
31
  end
33
32
 
34
- # For: Scrolling element hash item(s) into focus
33
+ # For: Scroll element hash item(s) into focus
35
34
  # Examples:
36
35
  # - I scroll to the first "home_screen" "logo_button" element hash
37
- When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{[\w\d]+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element hash$)) do |*args|
36
+ When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element hash$)) do |*args|
38
37
  key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
39
38
 
40
39
  AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
@@ -42,10 +41,10 @@ When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{[\w\d]+\}|all|random|l
42
41
  )
43
42
  end
44
43
 
45
- # For: Saving value from element hash for use later
44
+ # For: Save value from element hash for use later
46
45
  # Examples:
47
46
  # - I save "text" as "unique_value" from the first "home_screen" "logo_button" element hash
48
- When(%r(^I save "(\w+|%\{[\w\d]+\})" as "([\w\d]+)" from (?:the )?(%\{[\w\d]+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element hash$)) do |*args|
47
+ When(%r(^I save "(\w+|%\{\w+\})" as "(\w+)" from (?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element hash$)) do |*args|
49
48
  method, value_key, key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
50
49
 
51
50
  AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
@@ -56,40 +55,40 @@ When(%r(^I save "(\w+|%\{[\w\d]+\})" as "([\w\d]+)" from (?:the )?(%\{[\w\d]+\}|
56
55
  end
57
56
  end
58
57
 
59
- # For: Testing the element hashes size
58
+ # For: Test the element hashes size
60
59
  # Examples:
61
60
  # - the "home_screen" "title" element hash should be greater than 0
62
- Then(%r(^(?:the )?"([\w\d]+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element hash should(n't|not)? (?:be )?(larger th[ae]n|greater th[ae]n|less th[ae]n|smaller th[ae]n|equals?) (?:to )?(\d+)$)) do |*args|
61
+ Then(%r(^(?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element hash should(n't|not)? (?:be )?(larger th[ae]n|greater th[ae]n|less th[ae]n|smaller th[ae]n|equals?) (?:to )?(\d+)$)) do |*args|
63
62
  screen, element, negative, comparison, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
64
63
 
65
- element_hash = AutomationObject::Framework.get.send(screen).send(element)
64
+ element_hash = AutomationObject::Framework.get.screen(screen).element_hash(element)
66
65
  assert element_hash.is_a?(Hash)
67
66
 
68
67
  if comparison =~ /larger th[ae]n|greater th[ae]n/
69
68
  if negative
70
- refute expected_value < element_hash.keys.length
69
+ expect(expected_value).to_not be < element_hash.keys.length
71
70
  else
72
- assert expected_value < element_hash.keys.length
71
+ expect(expected_value).to be < element_hash.keys.length
73
72
  end
74
73
  elsif comparison =~ /smaller th[ae]n|less th[ae]n/
75
74
  if negative
76
- refute expected_value > element_hash.keys.length
75
+ expect(expected_value).to_not be > element_hash.keys.length
77
76
  else
78
- assert expected_value > element_hash.keys.length
77
+ expect(expected_value).to be > element_hash.keys.length
79
78
  end
80
79
  elsif comparison =~ /equals?/
81
80
  if negative
82
- refute_equals expected_value, element_hash.keys.length
81
+ expect(expected_value).to_not eq(element_hash.keys.length)
83
82
  else
84
- assert_equals expected_value, element_hash.keys.length
83
+ expect(expected_value).to eq(element_hash.keys.length)
85
84
  end
86
85
  end
87
86
  end
88
87
 
89
- # For: Testing if the element hash value equals a given value
88
+ # For: Test if the element hash value equals a given value
90
89
  # Examples:
91
90
  # - the first "home_screen" "title" element hash "text" should equal "Home"
92
- Then(%r(^(?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\})" "(\w+|%\{[\w\d]+\})" element hash "(\w+|%\{[\w\d]+\})" should ?(n't |not )?equal "(\w+|%\{[\w\d]+\})"$)) do |*args|
91
+ Then(%r(^(?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element hash "(\w+|%\{\w+\})" should ?(n't |not )?equal "(\w+|%\{\w+\})"$)) do |*args|
93
92
  key, low_range, high_range, screen, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
94
93
 
95
94
  AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
@@ -98,20 +97,20 @@ Then(%r(^(?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{[\w\d]+\}
98
97
  value = sub_element.send(method)
99
98
 
100
99
  if negative
101
- refute_equals expected_value, value
100
+ expect(expected_value).to_not eq(value)
102
101
  else
103
- assert_equals expected_value, value
102
+ expect(expected_value).to eq(value)
104
103
  end
105
104
  end
106
105
  end
107
106
 
108
- # For: Testing if the element hashes uniqueness
107
+ # For: Test if the element hash is unique
109
108
  # Examples:
110
109
  # - the "home_screen" "title" element hash "text" should be unique
111
- Then(%r(^(?:the )?"([\w\d]+|%\{[\w\d]+\})" "([\w\d]+|%\{[\w\d]+\})" element hash "([\w\d]+|%\{[\w\d]+\})" should(n't|not)? be unique$)) do |*args|
110
+ Then(%r(^(?:the )?"(\w+|%\{\w+\})" "(\w+|%\{\w+\})" element hash "(\w+|%\{\w+\})" should(n't|not)? be unique$)) do |*args|
112
111
  screen, element, method, negative = AutomationObject::StepDefinitions::Parse.new(args).get
113
112
 
114
- element_hash = AutomationObject::Framework.get.send(screen).send(element)
113
+ element_hash = AutomationObject::Framework.get.screen(screen).element_hash(element)
115
114
  assert element_hash.is_a?(Hash)
116
115
 
117
116
  values = []
@@ -120,8 +119,8 @@ Then(%r(^(?:the )?"([\w\d]+|%\{[\w\d]+\})" "([\w\d]+|%\{[\w\d]+\})" element hash
120
119
  end
121
120
 
122
121
  if negative
123
- refute_equals values.uniq, values
122
+ expect(values.uniq).to_not eq(values)
124
123
  else
125
- assert_equals values.uniq, values
124
+ expect(values.uniq).to eq(values)
126
125
  end
127
126
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'support/parse'
3
+
4
+ # Description: Provides step definitions related to modals
5
+
6
+ # For: Automatically navigate to the modal
7
+ # Examples:
8
+ # - I go to the "home_screen" "test_modal" modal
9
+ # - I go to "login_screen" "test_modal" modal
10
+ Then(%r(^I go to (?:the |)"([\w\s]+|%\{\w+\})" "([\w\s]+|%\{\w+\})" modal$)) do |*args|
11
+ screen, modal = AutomationObject::StepDefinitions::Parse.new(args).get
12
+
13
+ success = AutomationObject::Framework.get.screen(screen).modal(modal).go
14
+ expect(success).to eq(true)
15
+ end
16
+
17
+ # For: Test if modal is currently active
18
+ # Examples:
19
+ # - the "home_screen" "test_modal" modal should be active
20
+ # - the "login_screen" "test_modal" modal shouldn't be active
21
+ Then(%r(^the "([\w\s]+|%\{\w+\})" "([\w\s]+|%\{\w+\})" modal should ?(n't |not )?be active$)) do |*args|
22
+ screen, modal, negative = AutomationObject::StepDefinitions::Parse.new(args).get
23
+
24
+ active = AutomationObject::Framework.get.screen(screen).modal(modal).active?
25
+
26
+ if negative
27
+ expect(active).to eq(false)
28
+ else
29
+ expect(active).to eq(true)
30
+ end
31
+ end
@@ -1,29 +1,39 @@
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 screens
6
5
 
6
+ # For: Automatically navigate to the modal
7
+ # Examples:
8
+ # - I go to the "home_screen" screen
9
+ # - I go to "login_screen" screen
10
+ Then(%r(^I go to (?:the |)"([\w\s]+|%\{\w+\})" screen)) do |*args|
11
+ screen = AutomationObject::StepDefinitions::Parse.new(args).get
12
+
13
+ success = AutomationObject::Framework.get.screen(screen).go
14
+ expect(success).to eq(true)
15
+ end
16
+
7
17
  # For: Close the current screen or given screen
8
18
  # Examples:
9
19
  # - I close the "contact" screen
10
20
  # - I close the screen
11
21
  # - I destroy the screen
12
- Then(%r(^I (?:close|destroy) the ("([\w\s]+|%\{[\w\d]+\})")? ?screen$)) do |*args|
22
+ Then(%r(^I (?:close|destroy) the ("([\w\s]+|%\{\w+\})")? ?screen$)) do |*args|
13
23
  _unparsed_name, name = AutomationObject::StepDefinitions::Parse.new(args).get
14
24
 
15
25
  if name
16
- AutomationObject::Framework.get.screen(name).close
26
+ AutomationObject::Framework.get.send(name).close
17
27
  else
18
28
  AutomationObject::Framework.get.current_screen.close
19
29
  end
20
30
  end
21
31
 
22
- # For: Navigating back on a given or current screen
32
+ # For: Navigate back on a given or current screen
23
33
  # Examples:
24
34
  # - I navigate back on the screen
25
35
  # - I navigate back on the "contact" screen
26
- Then(%r(^I (?:navigate|go) back (?:on )?(?:the )?("([\w\s]+|%\{[\w\d]+\})")? ?screen$)) do
36
+ Then(%r(^I (?:navigate|go) back (?:on )?(?:the )?("([\w\s]+|%\{\w+\})")? ?screen$)) do
27
37
  _unparsed_name, name = AutomationObject::StepDefinitions::Parse.new(args).get
28
38
 
29
39
  if name
@@ -37,7 +47,7 @@ end
37
47
  # Examples:
38
48
  # - I switch to the "home" screen
39
49
  # - I focus the "contact" screen
40
- Then(%r(^I (?:switch|focus) (?:to )?(?:the )?"([\w\s]+|%\{[\w\d]+\})" screen$)) do |*args|
50
+ Then(%r(^I (?:switch|focus) (?:to )?(?:the )?"([\w\s]+|%\{\w+\})" screen$)) do |*args|
41
51
  screen = AutomationObject::StepDefinitions::Parse.new(args).get
42
52
  AutomationObject::Framework.get.focus(screen)
43
53
  end
@@ -48,7 +58,7 @@ end
48
58
  # - I set the "home" screen size to 1000x2000
49
59
  # - I set the screen width to 1000
50
60
  # - I set the screen height to 2000
51
- Then(%r(^I set the ("([\w\s]+|%\{[\w\d]+\})")? ?screen (size|width|height) to (\d+|(\d+)x(\d+))$)) do |*args|
61
+ Then(%r(^I set the ("([\w\s]+|%\{\w+\})")? ?screen (size|width|height) to (\d+|(\d+)x(\d+))$)) do |*args|
52
62
  _unparsed_screen, screen, dimension, size, width, height = AutomationObject::StepDefinitions::Parse.new(args).get
53
63
 
54
64
  screen = if screen
@@ -66,12 +76,14 @@ end
66
76
  # Examples:
67
77
  # - the "home" screen should be active
68
78
  # - the "login" screen shouldn't be active
69
- Then(%r(^the "([\w\s]+|%\{[\w\d]+\})" screen should ?(n't |not )?be active$)) do |*args|
79
+ Then(%r(^the "([\w\s]+|%\{\w+\})" screen should ?(n't |not )?be active$)) do |*args|
70
80
  screen, negative = AutomationObject::StepDefinitions::Parse.new(args).get
71
81
 
82
+ active = AutomationObject::Framework.get.screen(screen).active?
83
+
72
84
  if negative
73
- assert_equal false, AutomationObject::Framework.get.send(screen).active?
85
+ expect(active).to eq(false)
74
86
  else
75
- assert_equal true, AutomationObject::Framework.get.send(screen).active?
87
+ expect(active).to eq(true)
76
88
  end
77
89
  end
@@ -9,14 +9,17 @@ module AutomationObject
9
9
  # Singleton hash, create new if needed
10
10
  # @return [Hash] hash of values saved or new hash
11
11
  def values
12
- return @values if @values
13
- @values = {}
12
+ @values ||= {}
14
13
  end
15
14
 
15
+ # @return [Object]
16
16
  def get(key)
17
17
  values[key]
18
18
  end
19
19
 
20
+ # @param key [Object]
21
+ # @param value [Object]
22
+ # @return [void]
20
23
  def set(key, value)
21
24
  values[key] = value
22
25
  end
@@ -6,7 +6,7 @@ module AutomationObject
6
6
  module_function
7
7
 
8
8
  def iterate_and_do(screen, element, key, low_range, high_range)
9
- element_array = AutomationObject::Framework.get.send(screen).send(element)
9
+ element_array = AutomationObject::Framework.get.screen(screen).element_array(element)
10
10
  assert element_array.is_a?(Array)
11
11
 
12
12
  return range(element_array, low_range, high_range) if low_range && high_range
@@ -27,7 +27,7 @@ module AutomationObject
27
27
  def parse(string)
28
28
  return string if string.nil?
29
29
 
30
- string.scan(/%\{[\w\d]+\}/) do |cache_key|
30
+ string.scan(/%\{[\w]+\}/) do |cache_key|
31
31
  unwrapped_cache_key = cache_key.gsub(/[%\{\}]/, '')
32
32
 
33
33
  cached_value = AutomationObject::StepDefinitions::Cache.get(unwrapped_cache_key)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module AutomationObject
3
- VERSION = '0.7.6'
4
+ VERSION = '0.8.0'
4
5
  end