testcentricity_web 4.1.8 → 4.1.9
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/.gitignore +1 -0
- data/.rspec +2 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +13 -0
- data/README.md +11 -12
- data/Rakefile +93 -64
- data/config/cucumber.yml +1 -0
- data/config/locales/en-US.yml +56 -0
- data/{docker-compose-v3.yml → docker-compose.yml} +2 -2
- data/features/basic_form_page_css.feature +16 -1
- data/features/custom_controls.feature +29 -0
- data/features/media_players.feature +3 -20
- data/features/step_definitions/generic_steps.rb.rb +15 -0
- data/features/support/env.rb +3 -2
- data/features/support/hooks.rb +8 -3
- data/features/support/pages/base_test_page.rb +1 -1
- data/features/support/pages/basic_css_form_page.rb +1 -0
- data/features/support/pages/basic_form_page.rb +45 -9
- data/features/support/pages/basic_xpath_form_page.rb +1 -0
- data/features/support/pages/custom_controls_page.rb +250 -0
- data/features/support/pages/indexed_sections_page.rb +44 -0
- data/features/support/pages/media_test_page.rb +10 -11
- data/features/support/sections/header_nav.rb +10 -1
- data/features/support/sections/product_card.rb +39 -0
- data/lib/testcentricity_web/browser_helper.rb +0 -6
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/web_core/page_objects_helper.rb +1 -1
- data/lib/testcentricity_web/web_core/page_section.rb +1 -1
- data/lib/testcentricity_web/web_core/webdriver_helper.rb +44 -44
- data/lib/testcentricity_web/web_elements/checkbox.rb +50 -19
- data/lib/testcentricity_web/web_elements/media.rb +1 -1
- data/lib/testcentricity_web/web_elements/radio.rb +50 -19
- data/lib/testcentricity_web/web_elements/select_list.rb +12 -12
- data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +3 -3
- data/spec/fixtures/page_object.rb +22 -0
- data/spec/fixtures/section_object.rb +21 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/testcentricity_web/browser_spec.rb +41 -0
- data/spec/testcentricity_web/elements/audio_spec.rb +68 -0
- data/spec/testcentricity_web/elements/button_spec.rb +18 -0
- data/spec/testcentricity_web/elements/checkbox_spec.rb +33 -0
- data/spec/testcentricity_web/elements/file_field_spec.rb +13 -0
- data/spec/testcentricity_web/elements/image_spec.rb +33 -0
- data/spec/testcentricity_web/elements/label_spec.rb +18 -0
- data/spec/testcentricity_web/elements/link_spec.rb +23 -0
- data/spec/testcentricity_web/elements/list_spec.rb +13 -0
- data/spec/testcentricity_web/elements/radio_spec.rb +28 -0
- data/spec/testcentricity_web/elements/ui_element_spec.rb +125 -0
- data/spec/testcentricity_web/elements/video_spec.rb +68 -0
- data/spec/testcentricity_web/helper_specs/object_helpers_spec.rb +39 -0
- data/spec/testcentricity_web/helper_specs/string_helpers_spec.rb +49 -0
- data/spec/testcentricity_web/page_object_spec.rb +90 -0
- data/spec/testcentricity_web/section_object_spec.rb +72 -0
- data/spec/testcentricity_web/version_spec.rb +7 -0
- data/spec/testcentricity_web/webdriver_connect/grid_webdriver_spec.rb +72 -0
- data/spec/testcentricity_web/webdriver_connect/local_webdriver_spec.rb +86 -0
- data/spec/testcentricity_web/webdriver_connect/mobile_webdriver_spec.rb +65 -0
- data/test_site/basic_test_page.html +2 -2
- data/test_site/chosen-sprite.png +0 -0
- data/test_site/chosen-sprite@2x.png +0 -0
- data/test_site/chosen.css +496 -0
- data/test_site/chosen.jquery.js +1359 -0
- data/test_site/chosen.jquery.min.js +3 -0
- data/test_site/chosen.min.css +11 -0
- data/test_site/chosen.proto.js +1399 -0
- data/test_site/chosen.proto.min.js +3 -0
- data/test_site/composer.json +36 -0
- data/test_site/custom_controls_page.html +572 -1
- data/test_site/docsupport/chosen.png +0 -0
- data/test_site/docsupport/init.js +11 -0
- data/test_site/docsupport/init.proto.js +16 -0
- data/test_site/docsupport/jquery-1.12.4.min.js +5 -0
- data/test_site/docsupport/jquery-3.2.1.min.js +4 -0
- data/test_site/docsupport/oss-credit.png +0 -0
- data/test_site/docsupport/prism.css +108 -0
- data/test_site/docsupport/prism.js +9 -0
- data/test_site/docsupport/prototype-1.7.0.0.js +6082 -0
- data/test_site/docsupport/style.css +219 -0
- data/test_site/images/Blouse_Black.jpg +0 -0
- data/test_site/images/Printed_Dress.jpg +0 -0
- data/test_site/images/T-shirt.jpg +0 -0
- data/test_site/images/jeans3.jpg +0 -0
- data/test_site/indexed_sections_page.html +158 -1
- data/test_site/media/bbc_scotland_report.mp3 +0 -0
- data/test_site/media_page.html +2 -2
- data/testcentricity_web.gemspec +14 -8
- metadata +158 -13
- data/Gemfile.lock +0 -170
|
@@ -2,11 +2,13 @@ module TestCentricity
|
|
|
2
2
|
class CheckBox < UIElement
|
|
3
3
|
attr_accessor :proxy
|
|
4
4
|
attr_accessor :label
|
|
5
|
+
attr_accessor :input
|
|
5
6
|
|
|
6
7
|
def initialize(name, parent, locator, context)
|
|
7
8
|
super
|
|
8
9
|
@type = :checkbox
|
|
9
10
|
check_spec = {
|
|
11
|
+
input: nil,
|
|
10
12
|
proxy: nil,
|
|
11
13
|
label: nil
|
|
12
14
|
}
|
|
@@ -16,6 +18,8 @@ module TestCentricity
|
|
|
16
18
|
def define_custom_elements(element_spec)
|
|
17
19
|
element_spec.each do |element, value|
|
|
18
20
|
case element
|
|
21
|
+
when :input
|
|
22
|
+
@input = value
|
|
19
23
|
when :proxy
|
|
20
24
|
@proxy = value
|
|
21
25
|
when :label
|
|
@@ -44,9 +48,14 @@ module TestCentricity
|
|
|
44
48
|
# remember_me_checkbox.checked?
|
|
45
49
|
#
|
|
46
50
|
def checked?
|
|
47
|
-
|
|
48
|
-
object_not_found_exception(
|
|
49
|
-
|
|
51
|
+
@base_object, = find_element(:all)
|
|
52
|
+
object_not_found_exception(@base_object, 'Checkbox')
|
|
53
|
+
chk = if @input.nil?
|
|
54
|
+
@base_object
|
|
55
|
+
else
|
|
56
|
+
find_component(@input, 'checkbox')
|
|
57
|
+
end
|
|
58
|
+
chk.checked?
|
|
50
59
|
end
|
|
51
60
|
|
|
52
61
|
# Is checkbox state indeterminate?
|
|
@@ -67,7 +76,14 @@ module TestCentricity
|
|
|
67
76
|
# remember_me_checkbox.visible?
|
|
68
77
|
#
|
|
69
78
|
def visible?
|
|
70
|
-
@proxy.nil?
|
|
79
|
+
if @proxy.nil?
|
|
80
|
+
super
|
|
81
|
+
else
|
|
82
|
+
@base_object, = find_element(:all)
|
|
83
|
+
object_not_found_exception(@base_object, 'Checkbox')
|
|
84
|
+
proxy = find_component(@proxy, 'checkbox proxy')
|
|
85
|
+
proxy.visible?
|
|
86
|
+
end
|
|
71
87
|
end
|
|
72
88
|
|
|
73
89
|
# Is checkbox disabled (not enabled)?
|
|
@@ -77,10 +93,14 @@ module TestCentricity
|
|
|
77
93
|
# remember_me_checkbox.disabled?
|
|
78
94
|
#
|
|
79
95
|
def disabled?
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
if @input.nil?
|
|
97
|
+
super
|
|
98
|
+
else
|
|
99
|
+
@base_object, = find_element(:all)
|
|
100
|
+
object_not_found_exception(@base_object, 'Checkbox')
|
|
101
|
+
chk = find_component(@input, 'checkbox')
|
|
102
|
+
chk.disabled?
|
|
103
|
+
end
|
|
84
104
|
end
|
|
85
105
|
|
|
86
106
|
# Return checkbox caption
|
|
@@ -91,9 +111,15 @@ module TestCentricity
|
|
|
91
111
|
#
|
|
92
112
|
def get_value
|
|
93
113
|
if @label.nil?
|
|
94
|
-
@proxy.nil?
|
|
114
|
+
if @proxy.nil?
|
|
115
|
+
super
|
|
116
|
+
else
|
|
117
|
+
proxy = find_component(@proxy, 'checkbox proxy')
|
|
118
|
+
proxy.text
|
|
119
|
+
end
|
|
95
120
|
else
|
|
96
|
-
|
|
121
|
+
label = find_component(@label, 'checkbox label')
|
|
122
|
+
label.text
|
|
97
123
|
end
|
|
98
124
|
end
|
|
99
125
|
|
|
@@ -108,17 +134,22 @@ module TestCentricity
|
|
|
108
134
|
# remember_me_checkbox.set_checkbox_state(true)
|
|
109
135
|
#
|
|
110
136
|
def set_checkbox_state(state)
|
|
111
|
-
|
|
112
|
-
object_not_found_exception(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
137
|
+
@base_object, = find_element(:all)
|
|
138
|
+
object_not_found_exception(@base_object, 'Checkbox')
|
|
139
|
+
proxy = find_component(@proxy, 'checkbox proxy') unless @proxy.nil?
|
|
140
|
+
chk = find_component(@input, 'checkbox') unless @input.nil?
|
|
141
|
+
if @input.nil?
|
|
142
|
+
if @proxy.nil?
|
|
143
|
+
@base_object.click unless state == @base_object.checked?
|
|
144
|
+
else
|
|
145
|
+
proxy.click unless state == @base_object.checked?
|
|
119
146
|
end
|
|
120
147
|
else
|
|
121
|
-
|
|
148
|
+
if @proxy.nil?
|
|
149
|
+
@base_object.click unless state == chk.checked?
|
|
150
|
+
else
|
|
151
|
+
proxy.click unless state == chk.checked?
|
|
152
|
+
end
|
|
122
153
|
end
|
|
123
154
|
end
|
|
124
155
|
|
|
@@ -178,7 +178,7 @@ module TestCentricity
|
|
|
178
178
|
def ready_state
|
|
179
179
|
obj, = find_element(visible = :all)
|
|
180
180
|
object_not_found_exception(obj, @type)
|
|
181
|
-
|
|
181
|
+
page.execute_script('return arguments[0].readyState', obj)
|
|
182
182
|
end
|
|
183
183
|
|
|
184
184
|
# Wait until the media object's readyState value equals the specified value, or until the specified wait time has expired. If the wait
|
|
@@ -2,11 +2,13 @@ module TestCentricity
|
|
|
2
2
|
class Radio < UIElement
|
|
3
3
|
attr_accessor :proxy
|
|
4
4
|
attr_accessor :label
|
|
5
|
+
attr_accessor :input
|
|
5
6
|
|
|
6
7
|
def initialize(name, parent, locator, context)
|
|
7
8
|
super
|
|
8
9
|
@type = :radio
|
|
9
10
|
radio_spec = {
|
|
11
|
+
input: nil,
|
|
10
12
|
proxy: nil,
|
|
11
13
|
label: nil
|
|
12
14
|
}
|
|
@@ -16,6 +18,8 @@ module TestCentricity
|
|
|
16
18
|
def define_custom_elements(element_spec)
|
|
17
19
|
element_spec.each do |element, value|
|
|
18
20
|
case element
|
|
21
|
+
when :input
|
|
22
|
+
@input = value
|
|
19
23
|
when :proxy
|
|
20
24
|
@proxy = value
|
|
21
25
|
when :label
|
|
@@ -44,9 +48,14 @@ module TestCentricity
|
|
|
44
48
|
# accept_terms_radio.selected?
|
|
45
49
|
#
|
|
46
50
|
def selected?
|
|
47
|
-
|
|
48
|
-
object_not_found_exception(
|
|
49
|
-
|
|
51
|
+
@base_object, = find_element(:all)
|
|
52
|
+
object_not_found_exception(@base_object, 'Radio')
|
|
53
|
+
rad = if @input.nil?
|
|
54
|
+
@base_object
|
|
55
|
+
else
|
|
56
|
+
find_component(@input, 'Radio')
|
|
57
|
+
end
|
|
58
|
+
rad.checked?
|
|
50
59
|
end
|
|
51
60
|
|
|
52
61
|
# Is radio button visible?
|
|
@@ -56,7 +65,14 @@ module TestCentricity
|
|
|
56
65
|
# accept_terms_radio.visible?
|
|
57
66
|
#
|
|
58
67
|
def visible?
|
|
59
|
-
@proxy.nil?
|
|
68
|
+
if @proxy.nil?
|
|
69
|
+
super
|
|
70
|
+
else
|
|
71
|
+
@base_object, = find_element(:all)
|
|
72
|
+
object_not_found_exception(@base_object, 'Radio')
|
|
73
|
+
proxy = find_component(@proxy, 'radio proxy')
|
|
74
|
+
proxy.visible?
|
|
75
|
+
end
|
|
60
76
|
end
|
|
61
77
|
|
|
62
78
|
# Is radio button disabled (not enabled)?
|
|
@@ -66,10 +82,14 @@ module TestCentricity
|
|
|
66
82
|
# accept_terms_radio.disabled?
|
|
67
83
|
#
|
|
68
84
|
def disabled?
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
if @input.nil?
|
|
86
|
+
super
|
|
87
|
+
else
|
|
88
|
+
@base_object, = find_element(:all)
|
|
89
|
+
object_not_found_exception(@base_object, 'Radio')
|
|
90
|
+
rad = find_component(@input, 'radio')
|
|
91
|
+
rad.disabled?
|
|
92
|
+
end
|
|
73
93
|
end
|
|
74
94
|
|
|
75
95
|
# Return radio button caption
|
|
@@ -80,9 +100,15 @@ module TestCentricity
|
|
|
80
100
|
#
|
|
81
101
|
def get_value
|
|
82
102
|
if @label.nil?
|
|
83
|
-
@proxy.nil?
|
|
103
|
+
if @proxy.nil?
|
|
104
|
+
super
|
|
105
|
+
else
|
|
106
|
+
proxy = find_component(@proxy, 'radio proxy')
|
|
107
|
+
proxy.text
|
|
108
|
+
end
|
|
84
109
|
else
|
|
85
|
-
|
|
110
|
+
label = find_component(@label, 'radio label')
|
|
111
|
+
label.text
|
|
86
112
|
end
|
|
87
113
|
end
|
|
88
114
|
|
|
@@ -97,17 +123,22 @@ module TestCentricity
|
|
|
97
123
|
# accept_terms_radio.set_selected_state(true)
|
|
98
124
|
#
|
|
99
125
|
def set_selected_state(state)
|
|
100
|
-
|
|
101
|
-
object_not_found_exception(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
@base_object, = find_element(:all)
|
|
127
|
+
object_not_found_exception(@base_object, 'Radio')
|
|
128
|
+
proxy = find_component(@proxy, 'radio proxy') unless @proxy.nil?
|
|
129
|
+
rad = find_component(@input, 'radio') unless @input.nil?
|
|
130
|
+
if @input.nil?
|
|
131
|
+
if @proxy.nil?
|
|
132
|
+
@base_object.click unless state == @base_object.checked?
|
|
133
|
+
else
|
|
134
|
+
proxy.click unless state == @base_object.checked?
|
|
108
135
|
end
|
|
109
136
|
else
|
|
110
|
-
|
|
137
|
+
if @proxy.nil?
|
|
138
|
+
@base_object.click unless state == rad.checked?
|
|
139
|
+
else
|
|
140
|
+
proxy.click unless state == rad.checked?
|
|
141
|
+
end
|
|
111
142
|
end
|
|
112
143
|
end
|
|
113
144
|
|
|
@@ -61,7 +61,7 @@ module TestCentricity
|
|
|
61
61
|
#
|
|
62
62
|
def choose_option(option)
|
|
63
63
|
@base_object, = find_element
|
|
64
|
-
object_not_found_exception(@base_object,
|
|
64
|
+
object_not_found_exception(@base_object, 'SelectList')
|
|
65
65
|
|
|
66
66
|
trigger_list
|
|
67
67
|
|
|
@@ -75,9 +75,9 @@ module TestCentricity
|
|
|
75
75
|
end
|
|
76
76
|
else
|
|
77
77
|
if option.is_a?(Hash)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:index]})").click if option.key?(:index)
|
|
79
|
+
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:value]})").click if option.key?(:value)
|
|
80
|
+
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:text]})").click if option.key?(:text)
|
|
81
81
|
else
|
|
82
82
|
options = @base_object.all(@list_item).collect(&:text)
|
|
83
83
|
sleep(2) unless options.include?(option)
|
|
@@ -117,10 +117,10 @@ module TestCentricity
|
|
|
117
117
|
def set(text)
|
|
118
118
|
raise "A 'text_field' list element must be defined before calling the 'set' method on a selectlist object" if @text_field.nil?
|
|
119
119
|
@base_object, = find_element
|
|
120
|
-
object_not_found_exception(@base_object,
|
|
120
|
+
object_not_found_exception(@base_object, 'SelectList')
|
|
121
121
|
trigger_list
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
input = find_component(@text_field, 'text field')
|
|
123
|
+
input.set("#{text}\n")
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
# Return array of strings of all options in a select box object.
|
|
@@ -132,7 +132,7 @@ module TestCentricity
|
|
|
132
132
|
#
|
|
133
133
|
def get_options
|
|
134
134
|
@base_object, = find_element
|
|
135
|
-
object_not_found_exception(@base_object,
|
|
135
|
+
object_not_found_exception(@base_object, 'SelectList')
|
|
136
136
|
if @options_list.nil?
|
|
137
137
|
if @base_object.first(:css, @list_item, minimum: 0, wait: 2)
|
|
138
138
|
@base_object.all(@list_item).collect(&:text)
|
|
@@ -159,7 +159,7 @@ module TestCentricity
|
|
|
159
159
|
#
|
|
160
160
|
def get_option_count
|
|
161
161
|
@base_object, = find_element
|
|
162
|
-
object_not_found_exception(@base_object,
|
|
162
|
+
object_not_found_exception(@base_object, 'SelectList')
|
|
163
163
|
if @options_list.nil?
|
|
164
164
|
if @base_object.first(:css, @list_item, minimum: 0, wait: 2)
|
|
165
165
|
@base_object.all(@list_item).count
|
|
@@ -186,7 +186,7 @@ module TestCentricity
|
|
|
186
186
|
#
|
|
187
187
|
def get_group_headings
|
|
188
188
|
@base_object, = find_element
|
|
189
|
-
object_not_found_exception(@base_object,
|
|
189
|
+
object_not_found_exception(@base_object, 'SelectList')
|
|
190
190
|
if @options_list.nil?
|
|
191
191
|
if @base_object.first(:css, @group_heading, minimum: 0, wait: 2)
|
|
192
192
|
@base_object.all(@group_heading).collect(&:text)
|
|
@@ -211,7 +211,7 @@ module TestCentricity
|
|
|
211
211
|
#
|
|
212
212
|
def get_group_count
|
|
213
213
|
@base_object, = find_element
|
|
214
|
-
object_not_found_exception(@base_object,
|
|
214
|
+
object_not_found_exception(@base_object, 'SelectList')
|
|
215
215
|
if @options_list.nil?
|
|
216
216
|
if @base_object.first(:css, @group_item, minimum: 0, wait: 2)
|
|
217
217
|
@base_object.all(@group_item).count
|
|
@@ -245,7 +245,7 @@ module TestCentricity
|
|
|
245
245
|
#
|
|
246
246
|
def get_selected_option
|
|
247
247
|
@base_object, = find_element
|
|
248
|
-
object_not_found_exception(@base_object,
|
|
248
|
+
object_not_found_exception(@base_object, 'SelectList')
|
|
249
249
|
trigger_list unless @options_list.nil?
|
|
250
250
|
selection = if @base_object.first(:css, @list_item, minimum: 0, wait: 1, visible: :all)
|
|
251
251
|
@base_object.first(:css, @selected_item, wait: 1, visible: :all).text
|
|
@@ -527,7 +527,7 @@ module TestCentricity
|
|
|
527
527
|
else
|
|
528
528
|
obj.text
|
|
529
529
|
end
|
|
530
|
-
text.gsub(/[[:space:]]+/, ' ').strip
|
|
530
|
+
text.gsub(/[[:space:]]+/, ' ').strip unless text.nil?
|
|
531
531
|
end
|
|
532
532
|
|
|
533
533
|
alias get_caption get_value
|
|
@@ -1096,10 +1096,10 @@ module TestCentricity
|
|
|
1096
1096
|
|
|
1097
1097
|
def find_component(component, component_name)
|
|
1098
1098
|
begin
|
|
1099
|
-
element = @base_object.find(:css, component, minimum: 0, wait: 1)
|
|
1099
|
+
element = @base_object.find(:css, component, visible: :all, minimum: 0, wait: 1)
|
|
1100
1100
|
rescue
|
|
1101
1101
|
begin
|
|
1102
|
-
element = page.find(:css, component, minimum: 0, wait:
|
|
1102
|
+
element = page.find(:css, component, visible: :all, minimum: 0, wait: 2)
|
|
1103
1103
|
rescue
|
|
1104
1104
|
raise "Component #{component_name} (#{component}) for #{@type} named '#{@name}' (#{locator}) not found"
|
|
1105
1105
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class TestPage < TestCentricity::PageObject
|
|
2
|
+
trait(:page_name) { 'Basic Test Page' }
|
|
3
|
+
trait(:page_url) { '/basic_test_page.html' }
|
|
4
|
+
trait(:page_locator) { 'form#HTMLFormElements' }
|
|
5
|
+
|
|
6
|
+
elements element1: 'div#element1'
|
|
7
|
+
buttons button1: 'button#button1'
|
|
8
|
+
textfields field1: 'input#field1'
|
|
9
|
+
links link1: 'a#link1'
|
|
10
|
+
ranges range1: 'input#range1'
|
|
11
|
+
images image1: 'img#image1'
|
|
12
|
+
radios radio1: 'input#radio1'
|
|
13
|
+
checkboxes check1: 'input#check1'
|
|
14
|
+
filefields file1: 'input#file1'
|
|
15
|
+
labels label1: 'label#label1'
|
|
16
|
+
tables table1: 'table#table1'
|
|
17
|
+
selectlists select1: 'select#select1'
|
|
18
|
+
lists list1: 'ul#list1'
|
|
19
|
+
videos video1: 'video#video1'
|
|
20
|
+
audios audio1: 'audio#audio1'
|
|
21
|
+
sections section1: TestSection
|
|
22
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class TestSection < TestCentricity::PageSection
|
|
2
|
+
trait(:section_locator) { 'div#section' }
|
|
3
|
+
trait(:section_name) { 'Basic Test Section' }
|
|
4
|
+
|
|
5
|
+
elements element1: 'div#element1'
|
|
6
|
+
buttons button1: 'button#button1'
|
|
7
|
+
textfields field1: 'input#field1'
|
|
8
|
+
links link1: 'a#link1'
|
|
9
|
+
ranges range1: 'input#range1'
|
|
10
|
+
images image1: 'img#image1'
|
|
11
|
+
radios radio1: 'input#radio1'
|
|
12
|
+
checkboxes check1: 'input#check1'
|
|
13
|
+
filefields file1: 'input#file1'
|
|
14
|
+
labels label1: 'label#label1'
|
|
15
|
+
tables table1: 'table#table1'
|
|
16
|
+
selectlists select1: 'select#select1'
|
|
17
|
+
lists list1: 'ul#list1'
|
|
18
|
+
videos video1: 'video#video1'
|
|
19
|
+
audios audio1: 'audio#audio1'
|
|
20
|
+
sections section2: TestSection
|
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'require_all'
|
|
2
|
+
require 'capybara/rspec'
|
|
3
|
+
require 'httparty'
|
|
4
|
+
require 'simplecov'
|
|
5
|
+
require 'testcentricity_web'
|
|
6
|
+
|
|
7
|
+
require_rel 'fixtures'
|
|
8
|
+
|
|
9
|
+
include TestCentricity
|
|
10
|
+
|
|
11
|
+
SimpleCov.command_name("RSpec-#{Time.now.strftime('%Y%m%d%H%M%S')}")
|
|
12
|
+
|
|
13
|
+
$LOAD_PATH << './lib'
|
|
14
|
+
|
|
15
|
+
# set the default locale and auto load all translations from config/locales/*.rb,yml.
|
|
16
|
+
ENV['LOCALE'] = 'en-US' unless ENV['LOCALE']
|
|
17
|
+
I18n.load_path += Dir['config/locales/*.{rb,yml}']
|
|
18
|
+
I18n.default_locale = 'en-US'
|
|
19
|
+
I18n.locale = ENV['LOCALE']
|
|
20
|
+
Faker::Config.locale = ENV['LOCALE']
|
|
21
|
+
|
|
22
|
+
# prevent Test::Unit's AutoRunner from executing during RSpec's rake task
|
|
23
|
+
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
|
|
24
|
+
|
|
25
|
+
RSpec.configure do |config|
|
|
26
|
+
config.mock_with :rspec do |mocks|
|
|
27
|
+
mocks.allow_message_expectations_on_nil = true
|
|
28
|
+
mocks.verify_doubled_constant_names = true
|
|
29
|
+
mocks.verify_partial_doubles = true
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe TestCentricity::Browsers, required: true do
|
|
4
|
+
before(:context) do
|
|
5
|
+
# instantiate local test environment
|
|
6
|
+
@environs ||= EnvironData
|
|
7
|
+
@environs.find_environ('LOCAL', :yaml)
|
|
8
|
+
ENV['WEB_BROWSER'] = 'chrome_headless'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context 'web browser with multiple tabs/windows' do
|
|
12
|
+
it 'returns number of browser windows/tabs' do
|
|
13
|
+
WebDriverConnect.initialize_web_driver
|
|
14
|
+
Capybara.current_session.open_new_window
|
|
15
|
+
Capybara.current_session.open_new_window
|
|
16
|
+
expect(Browsers.num_browser_instances).to eql 3
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'closes original browser instance' do
|
|
20
|
+
WebDriverConnect.initialize_web_driver
|
|
21
|
+
Capybara.current_session.open_new_window
|
|
22
|
+
Browsers.close_old_browser_instance
|
|
23
|
+
expect(Browsers.num_browser_instances).to eql 1
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'closes current browser instance' do
|
|
27
|
+
WebDriverConnect.initialize_web_driver
|
|
28
|
+
Capybara.current_session.open_new_window
|
|
29
|
+
Browsers.switch_to_new_browser_instance
|
|
30
|
+
Capybara.current_session.open_new_window
|
|
31
|
+
Browsers.close_current_browser_instance
|
|
32
|
+
expect(Browsers.num_browser_instances).to eql 2
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after(:each) do
|
|
37
|
+
Browsers.close_all_browser_instances
|
|
38
|
+
Capybara.current_session.quit
|
|
39
|
+
Environ.session_state = :quit
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe TestCentricity::Audio, required: true do
|
|
4
|
+
subject(:css_audio) { described_class.new(:test_audio, self, 'audio#css_audio', :page) }
|
|
5
|
+
|
|
6
|
+
it 'returns class' do
|
|
7
|
+
expect(css_audio.class).to eql TestCentricity::Audio
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'registers with type audio' do
|
|
11
|
+
expect(css_audio.get_object_type).to eql :audio
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'returns autoplay' do
|
|
15
|
+
allow(css_audio).to receive(:autoplay?).and_return(false)
|
|
16
|
+
expect(css_audio.autoplay?).to eql false
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'returns controls' do
|
|
20
|
+
allow(css_audio).to receive(:controls?).and_return(true)
|
|
21
|
+
expect(css_audio.controls?).to eql true
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'returns ended' do
|
|
25
|
+
allow(css_audio).to receive(:ended?).and_return(true)
|
|
26
|
+
expect(css_audio.ended?).to eql true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'returns loop' do
|
|
30
|
+
allow(css_audio).to receive(:loop?).and_return(false)
|
|
31
|
+
expect(css_audio.loop?).to eql false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'returns muted' do
|
|
35
|
+
allow(css_audio).to receive(:muted?).and_return(false)
|
|
36
|
+
expect(css_audio.muted?).to eql false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'returns paused' do
|
|
40
|
+
allow(css_audio).to receive(:paused?).and_return(true)
|
|
41
|
+
expect(css_audio.paused?).to eql true
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'returns seeking' do
|
|
45
|
+
allow(css_audio).to receive(:seeking?).and_return(false)
|
|
46
|
+
expect(css_audio.seeking?).to eql false
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should play the audio' do
|
|
50
|
+
expect(css_audio).to receive(:play)
|
|
51
|
+
css_audio.play
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should pause the audio' do
|
|
55
|
+
expect(css_audio).to receive(:pause)
|
|
56
|
+
css_audio.pause
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'should mute the audio' do
|
|
60
|
+
expect(css_audio).to receive(:mute)
|
|
61
|
+
css_audio.mute
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'should unmute the audio' do
|
|
65
|
+
expect(css_audio).to receive(:unmute)
|
|
66
|
+
css_audio.unmute
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe TestCentricity::Button, required: true do
|
|
4
|
+
subject(:css_button) { described_class.new(:test_button, self, 'button#css_button', :page) }
|
|
5
|
+
|
|
6
|
+
it 'returns class' do
|
|
7
|
+
expect(css_button.class).to eql TestCentricity::Button
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'registers with type button' do
|
|
11
|
+
expect(css_button.get_object_type).to eql :button
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should click the button' do
|
|
15
|
+
expect(css_button).to receive(:click)
|
|
16
|
+
css_button.click
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe TestCentricity::CheckBox, required: true do
|
|
4
|
+
subject(:css_check) { described_class.new(:test_check, self, 'input#css_check', :page) }
|
|
5
|
+
|
|
6
|
+
it 'returns class' do
|
|
7
|
+
expect(css_check.class).to eql TestCentricity::CheckBox
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'registers with type checkbox' do
|
|
11
|
+
expect(css_check.get_object_type).to eql :checkbox
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should check the checkbox' do
|
|
15
|
+
expect(css_check).to receive(:check)
|
|
16
|
+
css_check.check
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should uncheck the checkbox' do
|
|
20
|
+
expect(css_check).to receive(:uncheck)
|
|
21
|
+
css_check.uncheck
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should know if checkbox is checked' do
|
|
25
|
+
allow(css_check).to receive(:checked?).and_return(true)
|
|
26
|
+
expect(css_check.checked?).to eq(true)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should know if checkbox is indeterminate' do
|
|
30
|
+
allow(css_check).to receive(:indeterminate?).and_return(true)
|
|
31
|
+
expect(css_check.indeterminate?).to eq(true)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe TestCentricity::FileField, required: true do
|
|
4
|
+
subject(:css_filefield) { described_class.new(:test_filefield, self, 'input#css_filefield', :page) }
|
|
5
|
+
|
|
6
|
+
it 'returns class' do
|
|
7
|
+
expect(css_filefield.class).to eql TestCentricity::FileField
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'registers with type label' do
|
|
11
|
+
expect(css_filefield.get_object_type).to eql :filefield
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe TestCentricity::Image, required: true do
|
|
4
|
+
subject(:css_image) { described_class.new(:test_image, self, 'img#css_image', :page) }
|
|
5
|
+
|
|
6
|
+
it 'returns class' do
|
|
7
|
+
expect(css_image.class).to eql TestCentricity::Image
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'registers with type image' do
|
|
11
|
+
expect(css_image.get_object_type).to eql :image
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'returns loaded' do
|
|
15
|
+
allow(css_image).to receive(:loaded?).and_return(true)
|
|
16
|
+
expect(css_image.loaded?).to eql true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'returns broken' do
|
|
20
|
+
allow(css_image).to receive(:broken?).and_return(false)
|
|
21
|
+
expect(css_image.broken?).to eql false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'returns alt' do
|
|
25
|
+
allow(css_image).to receive(:alt).and_return('alt')
|
|
26
|
+
expect(css_image.alt).to eql 'alt'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'returns src' do
|
|
30
|
+
allow(css_image).to receive(:src).and_return('src')
|
|
31
|
+
expect(css_image.src).to eql 'src'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe TestCentricity::Label, required: true do
|
|
4
|
+
subject(:css_label) { described_class.new(:test_label, self, 'label#css_label', :page) }
|
|
5
|
+
|
|
6
|
+
it 'returns class' do
|
|
7
|
+
expect(css_label.class).to eql TestCentricity::Label
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'registers with type label' do
|
|
11
|
+
expect(css_label.get_object_type).to eql :label
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'returns caption' do
|
|
15
|
+
allow(css_label).to receive(:caption).and_return('caption')
|
|
16
|
+
expect(css_label.caption).to eql 'caption'
|
|
17
|
+
end
|
|
18
|
+
end
|