automation_object 0.8.1 → 0.8.2
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.
- 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
@@ -42,16 +42,16 @@ module AutomationObject
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# Abstract argument, override
|
45
|
-
# @param
|
46
|
-
# @param
|
45
|
+
# @param _name [Symbol] name of child
|
46
|
+
# @param _options [Hash] options for child
|
47
47
|
# @return child [Object] return child composite object
|
48
48
|
def get_child(_name, _options)
|
49
49
|
raise 'Abstract method'
|
50
50
|
end
|
51
51
|
|
52
52
|
# Abstract argument, override
|
53
|
-
# @param
|
54
|
-
# @param
|
53
|
+
# @param _name [Symbol] name of child
|
54
|
+
# @param _options [Hash] options for child
|
55
55
|
# @return children [Hash] return children and names
|
56
56
|
def get_children(_name, _options)
|
57
57
|
raise 'Abstract method'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Require public page object classes for overriding
|
4
|
+
require_relative 'page_object/configuration'
|
5
|
+
require_relative 'page_object/screen'
|
6
|
+
require_relative 'page_object/modal'
|
7
|
+
require_relative 'page_object/element'
|
8
|
+
require_relative 'page_object/element_array'
|
9
|
+
require_relative 'page_object/element_hash'
|
10
|
+
|
11
|
+
module AutomationObject
|
12
|
+
# Public interface for PageObject
|
13
|
+
module PageObject
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module AutomationObject
|
2
|
+
module PageObject
|
3
|
+
class Base
|
4
|
+
class << self
|
5
|
+
attr_accessor :configuration
|
6
|
+
|
7
|
+
undef :configuration if defined? :configuration
|
8
|
+
def configuration
|
9
|
+
@configuration ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_property(name, value)
|
13
|
+
self.configuration[name] = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_property(name)
|
17
|
+
self.configuration[name]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module AutomationObject
|
4
|
+
module PageObject
|
5
|
+
class Configuration < Base
|
6
|
+
class << self
|
7
|
+
# Set base url
|
8
|
+
# @param url [String] base url
|
9
|
+
def base_url(url)
|
10
|
+
set_property(:base_url, url)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param name [Const]
|
14
|
+
def default_screen(name)
|
15
|
+
set_property(:default_screen, name)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param time [Numeric]
|
19
|
+
def screen_transition_sleep(time)
|
20
|
+
set_property(:screen_transition_sleep, time)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param hash [Hash]
|
24
|
+
def throttle_driver_methods(hash)
|
25
|
+
set_property(:throttle_driver_methods, hash)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param hash [Hash]
|
29
|
+
def throttle_element_methods(hash)
|
30
|
+
set_property(:throttle_element_methods, hash)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -7,20 +7,22 @@ require_relative 'support/parse'
|
|
7
7
|
# Examples:
|
8
8
|
# - I click on the "home_screen" "about_button" element
|
9
9
|
# - I hover over the "home_screen" "test_link" element
|
10
|
+
# - I hover over the "home_screen" "menu_modal" "test_link" element
|
10
11
|
# - I tap on "home_screen" "logo_button" element
|
11
|
-
When(%r(^I (\w+|%\{\w+\}) ?(?: on| over)? (?:the )?"(\w+|%\{\w+\})"
|
12
|
-
method, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
13
|
-
AutomationObject::Framework.get.screen(screen).element(element).send(method)
|
12
|
+
When(%r(^I (\w+|%\{\w+\}) ?(?: on| over)? (?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element$)) do |*args|
|
13
|
+
method, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
14
|
+
AutomationObject::Framework.get.screen(screen).modal(modal).element(element).send(method)
|
14
15
|
end
|
15
16
|
|
16
17
|
# For: Type into element field
|
17
18
|
# Examples:
|
18
19
|
# - I type "blah" into the "home_screen" "text_field" element
|
19
20
|
# - I type "test" in the "home_screen" "text_field" element
|
21
|
+
# - I type "test" in the "home_screen" "menu_modal" "text_field" element
|
20
22
|
# - I type "blah" in "home_screen" "text_field" element
|
21
|
-
When(%r(^I type "([^"]+|%\{\w+\})" in(?:to)? (?:the )?"(\w+|%\{\w+\})"
|
22
|
-
text, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
23
|
-
AutomationObject::Framework.get.screen(screen).element(element).send_keys(text)
|
23
|
+
When(%r(^I type "([^"]+|%\{\w+\})" in(?:to)? (?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element$)) do |*args|
|
24
|
+
text, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
25
|
+
AutomationObject::Framework.get.screen(screen).modal(modal).element(element).send_keys(text)
|
24
26
|
end
|
25
27
|
|
26
28
|
# For: Scroll element into focus
|
@@ -28,19 +30,21 @@ end
|
|
28
30
|
# - I scroll to the "home_screen" "logo_button" element
|
29
31
|
# - I focus to the "home_screen" "logo_button" element
|
30
32
|
# - I scroll to "home_screen" "logo_button" element
|
31
|
-
|
32
|
-
|
33
|
-
AutomationObject::
|
33
|
+
# - I scroll to "home_screen" "menu_modal" "logo_button" element
|
34
|
+
When(%r(^I (?:scroll |focus )to (?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element$)) do |*args|
|
35
|
+
screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
36
|
+
AutomationObject::Framework.get.screen(screen).modal(modal).element(element).scroll_into_view
|
34
37
|
end
|
35
38
|
|
36
39
|
# For: Save value from element for use later
|
37
40
|
# Examples:
|
38
41
|
# - I save "text" as "unique_value" from the "home_screen" "logo_button" element
|
39
42
|
# - I save "id" as "unique_value" from "home_screen" "logo_button" element
|
40
|
-
|
41
|
-
|
43
|
+
# - I save "id" as "unique_value" from "home_screen" "menu_modal" "logo_button" element
|
44
|
+
When(%r(^I save "(\w+|%\{\w+\})" as "(\w+)" from (?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element$)) do |*args|
|
45
|
+
method, key, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
42
46
|
# Save value from called method/property
|
43
|
-
value = AutomationObject::Framework.get.screen(screen).element(element).send(method)
|
47
|
+
value = AutomationObject::Framework.get.screen(screen).modal(modal).element(element).send(method)
|
44
48
|
AutomationObject::StepDefinitions::Cache.set(key, value)
|
45
49
|
end
|
46
50
|
|
@@ -49,10 +53,11 @@ end
|
|
49
53
|
# - the "home_screen" "title" element should exist
|
50
54
|
# - the "home_screen" "title" element shouldn't exist
|
51
55
|
# - "home_screen" "title" element should not exist
|
52
|
-
|
53
|
-
|
56
|
+
# - "home_screen" "menu_modal" "title" element should not exist
|
57
|
+
Then(%r(^(?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element should ?(n't |not )?exist$)) do |*args|
|
58
|
+
screen, modal, element, negative = AutomationObject::StepDefinitions::Parse.new(args).get
|
54
59
|
|
55
|
-
exists = AutomationObject::Framework.get.screen(screen).element(element).exists?
|
60
|
+
exists = AutomationObject::Framework.get.screen(screen).modal(modal).element(element).exists?
|
56
61
|
if negative
|
57
62
|
expect(exists).to eq(false)
|
58
63
|
else
|
@@ -64,11 +69,12 @@ end
|
|
64
69
|
# Examples:
|
65
70
|
# - the "home_screen" "title" element "text" should equal "Home"
|
66
71
|
# - "home_screen" "title" element "text" should not equal "About"
|
72
|
+
# - "home_screen" "menu_modal" "title" element "text" should not equal "About"
|
67
73
|
# - the "home_screen" "title" element "text" shouldn't equal "%{saved_value}"
|
68
|
-
Then(%r(^(?:the )?"(\w+|%\{\w+\})"
|
69
|
-
screen, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
74
|
+
Then(%r(^(?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element "(\w+|%\{\w+\})" should ?(n't |not )?equal "(\w+|%\{\w+\})"$)) do |*args|
|
75
|
+
screen, modal, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
70
76
|
|
71
|
-
actual_value = AutomationObject::Framework.get.screen(screen).element(element).send(method)
|
77
|
+
actual_value = AutomationObject::Framework.get.screen(screen).modal(modal).element(element).send(method)
|
72
78
|
if negative
|
73
79
|
expect(expected_value).not_to eq(actual_value)
|
74
80
|
else
|
@@ -9,12 +9,13 @@ require_relative 'support/element_array'
|
|
9
9
|
# - I click on the first "home_screen" "about_button" element array
|
10
10
|
# - I hover over all "home_screen" "about_button" element array
|
11
11
|
# - I click on 0..9 "home_screen" "about_button" element array
|
12
|
+
# - I click on 0..9 "home_screen" "menu_modal" "about_button" element array
|
12
13
|
# - I click on a random "home_screen" "about_button" element array
|
13
|
-
When(%r(^I (\w+|%\{\w+\})?(?: on| over)?(?: the| a)? (%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"
|
14
|
-
method, key, low_range, high_range, screen, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
14
|
+
When(%r(^I (\w+|%\{\w+\})?(?: on| over)?(?: the| a)? (%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element array$)) do |*args|
|
15
|
+
method, key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
15
16
|
|
16
17
|
AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
|
17
|
-
screen, element, key, low_range, high_range
|
18
|
+
screen, modal, element, key, low_range, high_range
|
18
19
|
) do |sub_element|
|
19
20
|
sub_element.send(method)
|
20
21
|
end
|
@@ -23,11 +24,12 @@ end
|
|
23
24
|
# For: Type into element array field
|
24
25
|
# Examples:
|
25
26
|
# - I type "blah" into the first "home_screen" "text_field" element array
|
26
|
-
|
27
|
-
|
27
|
+
# - I type "blah" into the first "home_screen" "menu_modal" "text_field" element array
|
28
|
+
When(%r(^I type "([\w\s]+|%\{\w+\})" in(?:to| to)? (?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element array$)) do |*args|
|
29
|
+
text, key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
28
30
|
|
29
31
|
AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
|
30
|
-
screen, element, key, low_range, high_range
|
32
|
+
screen, modal, element, key, low_range, high_range
|
31
33
|
) do |sub_element|
|
32
34
|
sub_element.send_keys(text)
|
33
35
|
end
|
@@ -36,22 +38,24 @@ end
|
|
36
38
|
# For: Scroll element array item(s) into focus
|
37
39
|
# Examples:
|
38
40
|
# - I scroll to the first "home_screen" "logo_button" element array
|
39
|
-
|
40
|
-
|
41
|
+
# - I scroll to the first "home_screen" "menu_modal" "logo_button" element array
|
42
|
+
When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element array$)) do |*args|
|
43
|
+
key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
41
44
|
|
42
45
|
AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
|
43
|
-
screen, element, key, low_range, high_range, &:scroll_into_view
|
46
|
+
screen, modal, element, key, low_range, high_range, &:scroll_into_view
|
44
47
|
)
|
45
48
|
end
|
46
49
|
|
47
50
|
# For: Save value from element array for use later
|
48
51
|
# Examples:
|
49
52
|
# - I save "text" as "unique_value" from the first "home_screen" "logo_button" element array
|
50
|
-
|
51
|
-
|
53
|
+
# - I save "text" as "unique_value" from the first "home_screen" "menu_modal" "logo_button" element array
|
54
|
+
When(%r(^I save "(\w+|%\{\w+\})" as "(\w+)" from (?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element array$)) do |*args|
|
55
|
+
method, value_key, key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
52
56
|
|
53
57
|
AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
|
54
|
-
screen, element, key, low_range, high_range
|
58
|
+
screen, modal, element, key, low_range, high_range
|
55
59
|
) do |sub_element|
|
56
60
|
value = sub_element.send(method)
|
57
61
|
AutomationObject::StepDefinitions::Cache.set(value_key, value)
|
@@ -61,10 +65,11 @@ end
|
|
61
65
|
# For: Test the element arrays length
|
62
66
|
# Examples:
|
63
67
|
# - the "home_screen" "title" element array should be greater than 0
|
64
|
-
|
65
|
-
|
68
|
+
# - the "home_screen" "menu_modal" "title" element array should be greater than 0
|
69
|
+
Then(%r(^(?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\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|
|
70
|
+
screen, modal, element, negative, comparison, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
66
71
|
|
67
|
-
element_array = AutomationObject::Framework.get.screen(screen).element_array(element)
|
72
|
+
element_array = AutomationObject::Framework.get.screen(screen).modal(modal).element_array(element)
|
68
73
|
assert element_array.is_a?(Array)
|
69
74
|
|
70
75
|
if comparison =~ /larger th[ae]n|greater th[ae]n/
|
@@ -93,13 +98,14 @@ end
|
|
93
98
|
# - the first "home_screen" "title" element array "text" should equal "Home"
|
94
99
|
# - the last "home_screen" "title" element array "text" shouldn't equal "Home"
|
95
100
|
# - the random "home_screen" "title" element array "text" should not equal "Home"
|
101
|
+
# - the random "home_screen" "menu_modal" "title" element array "text" should not equal "Home"
|
96
102
|
# - the 0..9 "home_screen" "title" element array "text" should equal "Home"
|
97
103
|
# - the all "home_screen" "title" element array "text" should not equal "Home"
|
98
|
-
Then(%r(^(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"
|
99
|
-
key, low_range, high_range, screen, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
104
|
+
Then(%r(^(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element array "(\w+|%\{\w+\})" should?(n't| not)? equal "(\w+|%\{\w+\})"$)) do |*args|
|
105
|
+
key, low_range, high_range, screen, modal, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
100
106
|
|
101
107
|
AutomationObject::StepDefinitions::ElementArray.iterate_and_do(
|
102
|
-
screen, element, key, low_range, high_range
|
108
|
+
screen, modal, element, key, low_range, high_range
|
103
109
|
) do |sub_element|
|
104
110
|
value = sub_element.send(method)
|
105
111
|
|
@@ -115,11 +121,12 @@ end
|
|
115
121
|
# Examples:
|
116
122
|
# - the "home_screen" "title" element array "text" should be unique
|
117
123
|
# - the "home_screen" "title" element array "text" should not be unique
|
124
|
+
# - the "home_screen" "menu_modal" "title" element array "text" should not be unique
|
118
125
|
# - the "home_screen" "title" element array "text" shouldn't be unique
|
119
|
-
Then(%r(^(?:the )?"(\w+|%\{\w+\})"
|
120
|
-
screen, element, method, negative = AutomationObject::StepDefinitions::Parse.new(args).get
|
126
|
+
Then(%r(^(?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element array "(\w+|%\{\w+\})" should(n't| not)? be unique$)) do |*args|
|
127
|
+
screen, modal, element, method, negative = AutomationObject::StepDefinitions::Parse.new(args).get
|
121
128
|
|
122
|
-
element_array = AutomationObject::Framework.get.screen(screen).element_array(element)
|
129
|
+
element_array = AutomationObject::Framework.get.screen(screen).modal(modal).element_array(element)
|
123
130
|
assert element_array.is_a?(Array)
|
124
131
|
|
125
132
|
values = []
|
@@ -7,11 +7,12 @@ require_relative 'support/element_hash'
|
|
7
7
|
# For: Call an element hash method
|
8
8
|
# Examples:
|
9
9
|
# - I click on the first "home_screen" "about_button" element hash
|
10
|
-
|
11
|
-
|
10
|
+
# - I click on the first "home_screen" "menu_modal" "about_button" element hash
|
11
|
+
When(%r(^I (\w+|%\{\w+\})?(?: on| over)?(?: the| a)? (%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element hash$)) do |*args|
|
12
|
+
method, key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
12
13
|
|
13
14
|
AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
|
14
|
-
screen, element, key, low_range, high_range
|
15
|
+
screen, modal, element, key, low_range, high_range
|
15
16
|
) do |sub_element|
|
16
17
|
sub_element.send(method)
|
17
18
|
end
|
@@ -20,11 +21,12 @@ end
|
|
20
21
|
# For: Type into element hash field
|
21
22
|
# Examples:
|
22
23
|
# - I type "blah" into the first "home_screen" "text_field" element hash
|
23
|
-
|
24
|
-
|
24
|
+
# - I type "blah" into the first "home_screen" "menu_modal" "text_field" element hash
|
25
|
+
When(%r(^I type "([\w\s]+|%\{\w+\})" in(?:to| to)? (?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element hash$)) do |*args|
|
26
|
+
text, key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
25
27
|
|
26
28
|
AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
|
27
|
-
screen, element, key, low_range, high_range
|
29
|
+
screen, modal, element, key, low_range, high_range
|
28
30
|
) do |sub_element|
|
29
31
|
sub_element.send_keys(text)
|
30
32
|
end
|
@@ -33,22 +35,24 @@ end
|
|
33
35
|
# For: Scroll element hash item(s) into focus
|
34
36
|
# Examples:
|
35
37
|
# - I scroll to the first "home_screen" "logo_button" element hash
|
36
|
-
|
37
|
-
|
38
|
+
# - I scroll to the first "home_screen" "menu_modal" "logo_button" element hash
|
39
|
+
When(%r(^I (?:scroll |focus )(?:to |through )(?:the )?(%\{\w+\}|all|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element hash$)) do |*args|
|
40
|
+
key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
38
41
|
|
39
42
|
AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
|
40
|
-
screen, element, key, low_range, high_range, &:scroll_into_view
|
43
|
+
screen, modal, element, key, low_range, high_range, &:scroll_into_view
|
41
44
|
)
|
42
45
|
end
|
43
46
|
|
44
47
|
# For: Save value from element hash for use later
|
45
48
|
# Examples:
|
46
49
|
# - I save "text" as "unique_value" from the first "home_screen" "logo_button" element hash
|
47
|
-
|
48
|
-
|
50
|
+
# - I save "text" as "unique_value" from the first "home_screen" "menu_modal" "logo_button" element hash
|
51
|
+
When(%r(^I save "(\w+|%\{\w+\})" as "(\w+)" from (?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element hash$)) do |*args|
|
52
|
+
method, value_key, key, low_range, high_range, screen, modal, element = AutomationObject::StepDefinitions::Parse.new(args).get
|
49
53
|
|
50
54
|
AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
|
51
|
-
screen, element, key, low_range, high_range
|
55
|
+
screen, modal, element, key, low_range, high_range
|
52
56
|
) do |sub_element|
|
53
57
|
value = sub_element.send(method)
|
54
58
|
AutomationObject::StepDefinitions::Cache.set(value_key, value)
|
@@ -58,10 +62,11 @@ end
|
|
58
62
|
# For: Test the element hashes size
|
59
63
|
# Examples:
|
60
64
|
# - the "home_screen" "title" element hash should be greater than 0
|
61
|
-
|
62
|
-
|
65
|
+
# - the "home_screen" "menu_modal" "title" element hash should be greater than 0
|
66
|
+
Then(%r(^(?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\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|
|
67
|
+
screen, modal, element, negative, comparison, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
63
68
|
|
64
|
-
element_hash = AutomationObject::Framework.get.screen(screen).element_hash(element)
|
69
|
+
element_hash = AutomationObject::Framework.get.screen(screen).modal(modal).element_hash(element)
|
65
70
|
assert element_hash.is_a?(Hash)
|
66
71
|
|
67
72
|
if comparison =~ /larger th[ae]n|greater th[ae]n/
|
@@ -88,11 +93,12 @@ end
|
|
88
93
|
# For: Test if the element hash value equals a given value
|
89
94
|
# Examples:
|
90
95
|
# - the first "home_screen" "title" element hash "text" should equal "Home"
|
91
|
-
|
92
|
-
|
96
|
+
# - the first "home_screen" "menu_modal" "title" element hash "text" should equal "Home"
|
97
|
+
Then(%r(^(?:the )?(%\{\w+\}|random|last|first|(\d+)\.\.(\d+)) "(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element hash "(\w+|%\{\w+\})" should ?(n't |not )?equal "(\w+|%\{\w+\})"$)) do |*args|
|
98
|
+
key, low_range, high_range, screen, modal, element, method, negative, expected_value = AutomationObject::StepDefinitions::Parse.new(args).get
|
93
99
|
|
94
100
|
AutomationObject::StepDefinitions::ElementHash.iterate_and_do(
|
95
|
-
screen, element, key, low_range, high_range
|
101
|
+
screen, modal, element, key, low_range, high_range
|
96
102
|
) do |sub_element|
|
97
103
|
value = sub_element.send(method)
|
98
104
|
|
@@ -107,10 +113,11 @@ end
|
|
107
113
|
# For: Test if the element hash is unique
|
108
114
|
# Examples:
|
109
115
|
# - the "home_screen" "title" element hash "text" should be unique
|
110
|
-
|
111
|
-
|
116
|
+
# - the "home_screen" "menu_modal" "title" element hash "text" should be unique
|
117
|
+
Then(%r(^(?:the )?"(\w+|%\{\w+\})"\s*"?(\w+|%\{\w+\})?"?\s*"(\w+|%\{\w+\})" element hash "(\w+|%\{\w+\})" should(n't|not)? be unique$)) do |*args|
|
118
|
+
screen, modal, element, method, negative = AutomationObject::StepDefinitions::Parse.new(args).get
|
112
119
|
|
113
|
-
element_hash = AutomationObject::Framework.get.screen(screen).element_hash(element)
|
120
|
+
element_hash = AutomationObject::Framework.get.screen(screen).modal(modal).element_hash(element)
|
114
121
|
assert element_hash.is_a?(Hash)
|
115
122
|
|
116
123
|
values = []
|