testcentricity_web 4.1.6 → 4.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -1
  4. data/.ruby-version +1 -0
  5. data/.simplecov +5 -1
  6. data/CHANGELOG.md +43 -0
  7. data/README.md +14 -13
  8. data/Rakefile +99 -21
  9. data/config/cucumber.yml +32 -11
  10. data/config/locales/en-US.yml +56 -0
  11. data/config/test_data/LOCAL_data.json +15 -0
  12. data/config/test_data/LOCAL_data.xls +0 -0
  13. data/config/test_data/LOCAL_data.yml +11 -0
  14. data/config/test_data/data.json +25 -0
  15. data/config/test_data/data.xls +0 -0
  16. data/config/test_data/data.yml +20 -0
  17. data/{docker-compose-v3.yml → docker-compose.yml} +2 -2
  18. data/features/basic_form_page_css.feature +54 -0
  19. data/features/basic_form_page_xpath.feature +26 -0
  20. data/features/custom_controls.feature +29 -0
  21. data/features/media_players.feature +67 -0
  22. data/features/step_definitions/generic_steps.rb.rb +87 -0
  23. data/features/step_definitions/media_steps.rb +30 -0
  24. data/features/support/data/form_data.rb +43 -0
  25. data/features/support/env.rb +18 -10
  26. data/features/support/hooks.rb +26 -1
  27. data/features/support/pages/base_test_page.rb +22 -0
  28. data/features/support/pages/{basic_css_test_page.rb → basic_css_form_page.rb} +12 -8
  29. data/features/support/pages/{basic_test_page.rb → basic_form_page.rb} +227 -36
  30. data/features/support/pages/{basic_xpath_test_page.rb → basic_xpath_form_page.rb} +12 -7
  31. data/features/support/pages/custom_controls_page.rb +263 -0
  32. data/features/support/pages/indexed_sections_page.rb +57 -0
  33. data/features/support/pages/media_test_page.rb +207 -0
  34. data/features/support/sections/header_nav.rb +48 -0
  35. data/features/support/sections/product_card.rb +39 -0
  36. data/features/support/world_data.rb +12 -0
  37. data/features/support/world_pages.rb +5 -2
  38. data/lib/testcentricity_web/appium_server.rb +5 -0
  39. data/lib/testcentricity_web/browser_helper.rb +0 -6
  40. data/lib/testcentricity_web/data_objects/data_objects_helper.rb +7 -0
  41. data/lib/testcentricity_web/data_objects/environment.rb +14 -0
  42. data/lib/testcentricity_web/data_objects/excel_helper.rb +60 -59
  43. data/lib/testcentricity_web/version.rb +1 -1
  44. data/lib/testcentricity_web/web_core/drag_drop_helper.rb +4 -0
  45. data/lib/testcentricity_web/web_core/page_object.rb +1 -8
  46. data/lib/testcentricity_web/web_core/page_objects_helper.rb +4 -2
  47. data/lib/testcentricity_web/web_core/page_section.rb +1 -1
  48. data/lib/testcentricity_web/web_core/webdriver_helper.rb +60 -44
  49. data/lib/testcentricity_web/web_elements/checkbox.rb +49 -19
  50. data/lib/testcentricity_web/web_elements/file_field.rb +9 -5
  51. data/lib/testcentricity_web/web_elements/image.rb +2 -1
  52. data/lib/testcentricity_web/web_elements/media.rb +46 -12
  53. data/lib/testcentricity_web/web_elements/radio.rb +51 -16
  54. data/lib/testcentricity_web/web_elements/select_list.rb +12 -12
  55. data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +22 -9
  56. data/lib/testcentricity_web/web_elements/video.rb +2 -2
  57. data/spec/fixtures/page_object.rb +22 -0
  58. data/spec/fixtures/section_object.rb +21 -0
  59. data/spec/spec_helper.rb +31 -0
  60. data/spec/testcentricity_web/browser_spec.rb +41 -0
  61. data/spec/testcentricity_web/elements/audio_spec.rb +68 -0
  62. data/spec/testcentricity_web/elements/button_spec.rb +18 -0
  63. data/spec/testcentricity_web/elements/checkbox_spec.rb +33 -0
  64. data/spec/testcentricity_web/elements/file_field_spec.rb +13 -0
  65. data/spec/testcentricity_web/elements/image_spec.rb +33 -0
  66. data/spec/testcentricity_web/elements/label_spec.rb +18 -0
  67. data/spec/testcentricity_web/elements/link_spec.rb +23 -0
  68. data/spec/testcentricity_web/elements/list_spec.rb +13 -0
  69. data/spec/testcentricity_web/elements/radio_spec.rb +28 -0
  70. data/spec/testcentricity_web/elements/ui_element_spec.rb +125 -0
  71. data/spec/testcentricity_web/elements/video_spec.rb +68 -0
  72. data/spec/testcentricity_web/helper_specs/object_helpers_spec.rb +39 -0
  73. data/spec/testcentricity_web/helper_specs/string_helpers_spec.rb +49 -0
  74. data/spec/testcentricity_web/page_object_spec.rb +90 -0
  75. data/spec/testcentricity_web/section_object_spec.rb +72 -0
  76. data/spec/testcentricity_web/version_spec.rb +7 -0
  77. data/spec/testcentricity_web/webdriver_connect/grid_webdriver_spec.rb +72 -0
  78. data/spec/testcentricity_web/webdriver_connect/local_webdriver_spec.rb +86 -0
  79. data/spec/testcentricity_web/webdriver_connect/mobile_webdriver_spec.rb +65 -0
  80. data/test_site/basic_test_page.html +51 -1
  81. data/test_site/chosen-sprite.png +0 -0
  82. data/test_site/chosen-sprite@2x.png +0 -0
  83. data/test_site/chosen.css +496 -0
  84. data/test_site/chosen.jquery.js +1359 -0
  85. data/test_site/chosen.jquery.min.js +3 -0
  86. data/test_site/chosen.min.css +11 -0
  87. data/test_site/chosen.proto.js +1399 -0
  88. data/test_site/chosen.proto.min.js +3 -0
  89. data/test_site/composer.json +36 -0
  90. data/test_site/custom_controls_page.html +629 -0
  91. data/test_site/docsupport/chosen.png +0 -0
  92. data/test_site/docsupport/init.js +11 -0
  93. data/test_site/docsupport/init.proto.js +16 -0
  94. data/test_site/docsupport/jquery-1.12.4.min.js +5 -0
  95. data/test_site/docsupport/jquery-3.2.1.min.js +4 -0
  96. data/test_site/docsupport/oss-credit.png +0 -0
  97. data/test_site/docsupport/prism.css +108 -0
  98. data/test_site/docsupport/prism.js +9 -0
  99. data/test_site/docsupport/prototype-1.7.0.0.js +6082 -0
  100. data/test_site/docsupport/style.css +219 -0
  101. data/test_site/images/Blouse_Black.jpg +0 -0
  102. data/test_site/images/Printed_Dress.jpg +0 -0
  103. data/test_site/images/T-shirt.jpg +0 -0
  104. data/test_site/images/jeans3.jpg +0 -0
  105. data/test_site/indexed_sections_page.html +215 -0
  106. data/test_site/media/MIB2-subtitles-pt-BR.vtt +49 -0
  107. data/test_site/media/MIB2.mp4 +0 -0
  108. data/test_site/media/bbc_scotland_report.mp3 +0 -0
  109. data/test_site/media/count_and_bars.mp4 +0 -0
  110. data/test_site/media_page.html +60 -7
  111. data/testcentricity_web.gemspec +14 -8
  112. metadata +197 -25
  113. data/Gemfile.lock +0 -170
  114. data/features/basic_test_page_css.feature +0 -24
  115. data/features/basic_test_page_xpath.feature +0 -24
  116. data/features/support/pages/media_page.rb +0 -11
@@ -1,8 +1,41 @@
1
- # Page Object class definition for Basic HTML Test page
1
+ # Page Object class definition for Basic HTML Form page
2
2
 
3
- class BasicTestPage < TestCentricity::PageObject
3
+ class BasicFormPage < BaseTestPage
4
4
  trait(:page_url) { '/basic_test_page.html' }
5
+ trait(:navigator) { header_nav.open_form_page }
6
+ trait(:page_title) { 'Basic HTML Form'}
5
7
  trait(:tab_order) {
8
+ [
9
+ header_nav.form_link,
10
+ header_nav.media_link,
11
+ header_nav.indexed_sections_link,
12
+ header_nav.custom_controls_link,
13
+ username_field,
14
+ password_field,
15
+ max_length_field,
16
+ read_only_field,
17
+ number_field,
18
+ color_picker,
19
+ slider,
20
+ comments_field,
21
+ upload_file,
22
+ check_1,
23
+ check_2,
24
+ check_3,
25
+ radio_1,
26
+ [
27
+ radio_2,
28
+ radio_3
29
+ ],
30
+ multi_select,
31
+ drop_down_select,
32
+ link_1,
33
+ link_2,
34
+ cancel_button,
35
+ submit_button
36
+ ]
37
+ }
38
+ trait(:firefox_order) {
6
39
  [
7
40
  username_field,
8
41
  password_field,
@@ -41,17 +74,44 @@ class BasicTestPage < TestCentricity::PageObject
41
74
  }
42
75
 
43
76
  def verify_page_ui
77
+ super
78
+
79
+ verify_page_contains(page_title)
80
+ image_1.wait_until_loaded(5)
81
+ username_field.scroll_to(:center) if username_field.obscured?
44
82
  ui = {
45
- self => { exists: true, secure: false, title: 'Basic HTML Form' },
46
- header_label => { visible: true, caption: 'Basic HTML Form Example' },
47
83
  username_label => { visible: true, caption: 'Username:' },
48
- username_field => { visible: true, enabled: true, required: true, value: '', placeholder: 'User name' },
84
+ username_field => {
85
+ name: 'username',
86
+ exists: true,
87
+ displayed: true,
88
+ obscured: false,
89
+ visible: true,
90
+ hidden: false,
91
+ enabled: true,
92
+ disabled: false,
93
+ required: true,
94
+ value: '',
95
+ placeholder: 'User name'
96
+ },
49
97
  password_label => { visible: true, caption: 'Password:' },
50
- password_field => { visible: true, enabled: true, required: true, value: '', placeholder: 'Password' },
98
+ password_field => {
99
+ name: 'password',
100
+ visible: true,
101
+ displayed: true,
102
+ obscured: false,
103
+ focused: false,
104
+ enabled: true,
105
+ required: true,
106
+ value: '',
107
+ placeholder: 'Password'
108
+ },
51
109
  max_length_label => { visible: true, caption: 'Max Length:' },
52
110
  max_length_field => {
53
111
  visible: true,
112
+ obscured: false,
54
113
  enabled: true,
114
+ focused: false,
55
115
  placeholder: 'up to 64 characters',
56
116
  value: '',
57
117
  maxlength: 64
@@ -87,15 +147,75 @@ class BasicTestPage < TestCentricity::PageObject
87
147
  filename_label => { visible: true, caption: 'Filename:' },
88
148
  upload_file => { visible: true, enabled: true, value: '' },
89
149
  checkboxes_label => { visible: true, caption: 'Checkbox Items:' },
90
- check_1 => { visible: true, enabled: true, checked: false },
91
- check_2 => { visible: true, enabled: true, checked: false },
92
- check_3 => { visible: true, enabled: true, checked: false },
93
- check_4 => { visible: true, enabled: false, checked: false },
150
+ check_1 => {
151
+ exists: true,
152
+ visible: true,
153
+ hidden: false,
154
+ enabled: true,
155
+ disabled: false,
156
+ checked: false,
157
+ indeterminate: false
158
+ },
159
+ check_2 => {
160
+ exists: true,
161
+ visible: true,
162
+ hidden: false,
163
+ enabled: true,
164
+ disabled: false,
165
+ checked: false,
166
+ indeterminate: false
167
+ },
168
+ check_3 => {
169
+ exists: true,
170
+ visible: true,
171
+ hidden: false,
172
+ enabled: true,
173
+ disabled: false,
174
+ checked: false,
175
+ indeterminate: false
176
+ },
177
+ check_4 => {
178
+ exists: true,
179
+ visible: true,
180
+ hidden: false,
181
+ enabled: false,
182
+ disabled: true,
183
+ checked: false,
184
+ indeterminate: false
185
+ },
94
186
  radios_label => { visible: true, caption: 'Radio Items:' },
95
- radio_1 => { visible: true, enabled: true, selected: false },
96
- radio_2 => { visible: true, enabled: true, selected: false },
97
- radio_3 => { visible: true, enabled: true, selected: false },
98
- radio_4 => { visible: true, enabled: false, selected: false },
187
+ radio_1 => {
188
+ exists: true,
189
+ visible: true,
190
+ hidden: false,
191
+ enabled: true,
192
+ disabled: false,
193
+ selected: false
194
+ },
195
+ radio_2 => {
196
+ exists: true,
197
+ visible: true,
198
+ hidden: false,
199
+ enabled: true,
200
+ disabled: false,
201
+ selected: false
202
+ },
203
+ radio_3 => {
204
+ exists: true,
205
+ visible: true,
206
+ hidden: false,
207
+ enabled: true,
208
+ disabled: false,
209
+ selected: false
210
+ },
211
+ radio_4 => {
212
+ exists: true,
213
+ visible: true,
214
+ hidden: false,
215
+ enabled: false,
216
+ disabled: true,
217
+ selected: false
218
+ },
99
219
  multiselect_label => { visible: true, caption: 'Multiple Select Values:' },
100
220
  multi_select => {
101
221
  visible: true,
@@ -112,6 +232,29 @@ class BasicTestPage < TestCentricity::PageObject
112
232
  options: ['Drop Down Item 1', 'Drop Down Item 2', 'Drop Down Item 3', 'Drop Down Item 4', 'Drop Down Item 5', 'Drop Down Item 6'],
113
233
  selected: 'Drop Down Item 1'
114
234
  },
235
+ link_label => { visible: true, caption: 'Links:' },
236
+ links_list => {
237
+ visible: true,
238
+ enabled: true,
239
+ itemcount: 3,
240
+ items: ['Open Media Page in same window/tab', 'Open Media Page in a new window/tab', 'Disabled Link']
241
+ },
242
+ link_1 => {
243
+ visible: true,
244
+ href: { ends_with: 'media_page.html' },
245
+ caption: 'Open Media Page in same window/tab'
246
+ },
247
+ link_2 => {
248
+ visible: true,
249
+ href: { ends_with: 'media_page.html' },
250
+ caption: 'Open Media Page in a new window/tab'
251
+ },
252
+ link_3 => {
253
+ visible: true,
254
+ aria_disabled: true,
255
+ role: 'link',
256
+ caption: 'Disabled Link'
257
+ },
115
258
  table_label => { visible: true, caption: 'Table:' },
116
259
  static_table => {
117
260
  visible: true,
@@ -121,17 +264,22 @@ class BasicTestPage < TestCentricity::PageObject
121
264
  { row: 1 } => [['Alfreds Futterkiste', 'Maria Anders', 'Germany']],
122
265
  { row: 2 } => [['Centro comercial Moctezuma', 'Francisco Chang', 'Mexico']],
123
266
  { row: 3 } => [['Ernst Handel', 'Roland Mendel', 'Austria']],
124
- { row: 4 } => [['Island Trading', 'Helen Bennett', 'UK']]
267
+ { row: 4 } => [['Island Trading', 'Helen Bennett', 'UK']],
268
+ { cell: [1, 3] } => ['Germany'],
269
+ { cell: [2, 3] } => ['Mexico'],
270
+ { column: 3 } => [['Germany', 'Mexico', 'Austria', 'UK']]
125
271
  },
126
272
  images_label => { visible: true, caption: 'Images:' },
127
273
  image_1 => {
128
274
  visible: true,
275
+ loaded: true,
129
276
  broken: false,
130
277
  src: { ends_with: 'images/Wilder.jpg' },
131
278
  alt: "It's alive"
132
279
  },
133
280
  image_2 => {
134
281
  visible: true,
282
+ loaded: true,
135
283
  broken: false,
136
284
  src: { ends_with: 'images/You_Betcha.jpg' },
137
285
  alt: 'You Betcha'
@@ -149,29 +297,45 @@ class BasicTestPage < TestCentricity::PageObject
149
297
  end
150
298
 
151
299
  def form_data
152
- file_path = Environ.platform == :mobile ? nil : "#{Dir.pwd}/test_site/images/Wilder.jpg"
300
+ data = form_data_source.read_form_data
301
+
302
+ if Environ.platform == :mobile
303
+ file_path = nil
304
+ file_name = ''
305
+ color_value = '#000000'
306
+ else
307
+ file_path = "#{Dir.pwd}/test_site/images/#{data.image_filename}"
308
+ file_name = data.image_filename
309
+ color_value = Faker::Color.hex_color
310
+ end
153
311
  {
154
- username: Faker::Name.name,
155
- password: 'T0p_Sekrit',
312
+ username: data.username,
313
+ password: data.password,
156
314
  maxlength: Faker::Marketing.buzzwords,
157
315
  number: Faker::Number.between(from: 10, to: 1024),
158
- color: Faker::Color.hex_color,
159
- slider: 45,
316
+ color: color_value,
317
+ slider: 50,
160
318
  comments: Faker::Hipster.paragraph,
161
319
  filepath: file_path,
162
- filename: "Wilder.jpg",
163
- check1: true,
164
- check2: true,
165
- check3: false,
166
- radio1: true,
167
- radio2: false,
168
- radio3: false,
169
- multi_select: 'Selection Item 2',
170
- drop_select: 'Drop Down Item 5'
320
+ filename: file_name,
321
+ check1: data.check1,
322
+ check2: data.check2,
323
+ check3: data.check3,
324
+ radio_select: data.radio_select,
325
+ multi_select: data.multi_select,
326
+ drop_select: data.drop_down_item
171
327
  }
172
328
  end
173
329
 
174
330
  def populate_form
331
+ # toggle checks and radios and verify
332
+ check_2.check
333
+ check_2.verify_check_state(true)
334
+ check_2.uncheck
335
+ check_2.verify_check_state(false)
336
+ radio_2.select
337
+ radio_2.unselect
338
+ # populate fields and controls with externally sourced data
175
339
  @data = form_data
176
340
  fields = {
177
341
  username_field => @data[:username],
@@ -185,9 +349,9 @@ class BasicTestPage < TestCentricity::PageObject
185
349
  check_1 => @data[:check1],
186
350
  check_2 => @data[:check2],
187
351
  check_3 => @data[:check3],
188
- radio_1 => @data[:radio1],
189
- radio_2 => @data[:radio2],
190
- radio_3 => @data[:radio3],
352
+ radio_1 => @data[:radio_select] == 1,
353
+ radio_2 => @data[:radio_select] == 2,
354
+ radio_3 => @data[:radio_select] == 3,
191
355
  multi_select => @data[:multi_select],
192
356
  drop_down_select => @data[:drop_select]
193
357
  }
@@ -207,9 +371,9 @@ class BasicTestPage < TestCentricity::PageObject
207
371
  check_1 => { checked: @data[:check1] },
208
372
  check_2 => { checked: @data[:check2] },
209
373
  check_3 => { checked: @data[:check3] },
210
- radio_1 => { selected: @data[:radio1] },
211
- radio_2 => { selected: @data[:radio2] },
212
- radio_3 => { selected: @data[:radio3] },
374
+ radio_1 => { selected: @data[:radio_select] == 1 },
375
+ radio_2 => { selected: @data[:radio_select] == 2 },
376
+ radio_3 => { selected: @data[:radio_select] == 3 },
213
377
  multi_select => { selected: @data[:multi_select] },
214
378
  drop_down_select => { selected: @data[:drop_select] }
215
379
  }
@@ -228,11 +392,38 @@ class BasicTestPage < TestCentricity::PageObject
228
392
  end
229
393
 
230
394
  def verify_tab_order
231
- order = if Environ.browser == :safari
395
+ order = case Environ.browser
396
+ when :safari
232
397
  safari_tab_order
398
+ when :firefox
399
+ firefox_order
233
400
  else
234
401
  tab_order
235
402
  end
236
403
  verify_focus_order(order)
237
404
  end
405
+
406
+ def choose_options_by(method)
407
+ case method.downcase.to_sym
408
+ when :index
409
+ multi_select.choose_option(index: 2)
410
+ drop_down_select.choose_option(index: 3)
411
+ when :value
412
+ multi_select.choose_option(value: 'ms2')
413
+ drop_down_select.choose_option(value: 'dd3')
414
+ when :text
415
+ multi_select.choose_option(text: 'Selection Item 2')
416
+ drop_down_select.choose_option(text: 'Drop Down Item 3')
417
+ else
418
+ raise "#{method} is not a valid selector"
419
+ end
420
+ end
421
+
422
+ def verify_chosen_options
423
+ ui = {
424
+ multi_select => { selected: 'Selection Item 2' },
425
+ drop_down_select => { selected: 'Drop Down Item 3' }
426
+ }
427
+ verify_ui_states(ui)
428
+ end
238
429
  end
@@ -1,7 +1,7 @@
1
- # Page Object class definition for Basic HTML Test page with Xpath locators
1
+ # Page Object class definition for Basic HTML Form page with Xpath locators
2
2
 
3
- class BasicXpathTestPage < BasicTestPage
4
- trait(:page_name) { 'Basic Xpath Test' }
3
+ class BasicXpathFormPage < BasicFormPage
4
+ trait(:page_name) { 'Basic Xpath Form' }
5
5
  trait(:page_locator) { "//form[@id='HTMLFormElements']" }
6
6
 
7
7
  # Basic HTML Test page UI elements
@@ -12,8 +12,8 @@ class BasicXpathTestPage < BasicTestPage
12
12
  number_field: "//input[@id='number-field']",
13
13
  comments_field: "//textarea[@id='comments']",
14
14
  color_picker: "//input[@id='color-picker']"
15
- range :slider, "//input[@id='slider']"
16
- filefield :upload_file, "//input[@id='filename']"
15
+ ranges slider: "//input[@id='slider']"
16
+ filefields upload_file: "//input[@id='filename']"
17
17
  checkboxes check_1: "//input[@id='check1']",
18
18
  check_2: "//input[@id='check2']",
19
19
  check_3: "//input[@id='check3']",
@@ -24,13 +24,17 @@ class BasicXpathTestPage < BasicTestPage
24
24
  radio_4: "//input[@id='radio4']"
25
25
  selectlists multi_select: "//select[@id='multipleselect']",
26
26
  drop_down_select: "//select[@id='dropdown']"
27
- table :static_table, "//table[@id='table']"
27
+ lists links_list: "//ul[@id='links_list']"
28
+ links link_1: "//a[@id='link1']",
29
+ link_2: "//a[@id='link2']",
30
+ link_3: "//a[@id='link3']"
31
+ tables static_table: "//table[@id='table']"
28
32
  images image_1: "//img[@id='image1']",
29
33
  image_2: "//img[@id='image2']",
30
34
  image_3: "//img[@id='image3']"
31
35
  buttons cancel_button: "//input[@id='cancel']",
32
36
  submit_button: "//input[@id='submit']"
33
- labels header_label: '//h1',
37
+ labels header_label: '//h2',
34
38
  username_label: "//label[@for='username']",
35
39
  password_label: "//label[@for='password']",
36
40
  max_length_label: "//label[@for='maxlength']",
@@ -44,6 +48,7 @@ class BasicXpathTestPage < BasicTestPage
44
48
  radios_label: "//label[@id='radios']",
45
49
  multiselect_label: "//label[@for='multipleselect']",
46
50
  dropdown_label: "//label[@for='dropdown']",
51
+ link_label: "//label[@id='links']",
47
52
  table_label: "//label[@for='table']",
48
53
  images_label: "//label[@id='images']"
49
54
  end
@@ -0,0 +1,263 @@
1
+ # Page Object class definition for Custom Controls page with CSS locators
2
+
3
+ class CustomControlsPage < BaseTestPage
4
+ trait(:page_name) { 'Custom Controls' }
5
+ trait(:page_locator) { 'div.custom-controls-page-body' }
6
+ trait(:page_url) { '/custom_controls_page.html' }
7
+ trait(:navigator) { header_nav.open_custom_controls_page }
8
+ trait(:page_title) { 'Custom Controls Page'}
9
+ trait(:divisions) {
10
+ ['NFC EAST',
11
+ 'NFC NORTH',
12
+ 'NFC SOUTH',
13
+ 'NFC WEST',
14
+ 'AFC EAST',
15
+ 'AFC NORTH',
16
+ 'AFC SOUTH',
17
+ 'AFC WEST']
18
+ }
19
+ trait(:teams) {
20
+ ['Dallas Cowboys',
21
+ 'New York Giants',
22
+ 'Philadelphia Eagles',
23
+ 'Washington Redskins',
24
+ 'Chicago Bears',
25
+ 'Detroit Lions',
26
+ 'Green Bay Packers',
27
+ 'Minnesota Vikings',
28
+ 'Atlanta Falcons',
29
+ 'Carolina Panthers',
30
+ 'New Orleans Saints',
31
+ 'Tampa Bay Buccaneers',
32
+ 'Arizona Cardinals',
33
+ 'St. Louis Rams',
34
+ 'San Francisco 49ers',
35
+ 'Seattle Seahawks',
36
+ 'Buffalo Bills',
37
+ 'Miami Dolphins',
38
+ 'New England Patriots',
39
+ 'New York Jets',
40
+ 'Baltimore Ravens',
41
+ 'Cincinnati Bengals',
42
+ 'Cleveland Browns',
43
+ 'Pittsburgh Steelers',
44
+ 'Houston Texans',
45
+ 'Indianapolis Colts',
46
+ 'Jacksonville Jaguars',
47
+ 'Tennessee Titans',
48
+ 'Denver Broncos',
49
+ 'Kansas City Chiefs',
50
+ 'Oakland Raiders',
51
+ 'San Diego Chargers']
52
+ }
53
+ trait(:countries) { ['United Kingdom', 'Tonga', 'Sweden', 'Peru', 'Belize', 'Mali', 'Ireland'] }
54
+
55
+ # Custom Controls page UI elements
56
+ selectlists country_select: 'div#country_chosen',
57
+ team_select: 'div#team_chosen'
58
+ checkboxes pork_check: "label[for='check1']",
59
+ beef_check: "label[for='check2']",
60
+ chicken_check: "label[for='check3']",
61
+ shrimp_check: "label[for='check4']"
62
+ radios mild_radio: "label[for='radio1']",
63
+ spicey_radio: "label[for='radio2']",
64
+ hot_radio: "label[for='radio3']",
65
+ flaming_radio: "label[for='radio4']"
66
+ tables custom_table: 'div#resp-table'
67
+
68
+ attr_accessor :selected_country
69
+ attr_accessor :selected_team
70
+ attr_accessor :selected_checks
71
+ attr_accessor :selected_radio
72
+
73
+ def initialize
74
+ super
75
+ # define the custom list element components for the Country and Team Chosen selectlists
76
+ list_spec = {
77
+ selected_item: "li[class*='result-selected']",
78
+ list_item: "li[class*='active-result']",
79
+ text_field: 'input.chosen-search-input',
80
+ options_list: 'ul.chosen-results',
81
+ group_item: 'li.group-result',
82
+ group_heading: 'li.group-result'
83
+ }
84
+ country_select.define_list_elements(list_spec)
85
+ team_select.define_list_elements(list_spec)
86
+ # define the custom element components for the checkboxes
87
+ check_spec = { input: "input[type='checkbox']" }
88
+ pork_check.define_custom_elements(check_spec)
89
+ beef_check.define_custom_elements(check_spec)
90
+ chicken_check.define_custom_elements(check_spec)
91
+ shrimp_check.define_custom_elements(check_spec)
92
+ # define the custom element components for the radios
93
+ radio_spec = { input: "input[type='radio']" }
94
+ mild_radio.define_custom_elements(radio_spec)
95
+ spicey_radio.define_custom_elements(radio_spec)
96
+ hot_radio.define_custom_elements(radio_spec)
97
+ flaming_radio.define_custom_elements(radio_spec)
98
+ # define the custom element components for the table
99
+ table_spec = {
100
+ table_body: 'div#resp-table-body',
101
+ table_row: 'div.resp-table-row',
102
+ table_column: 'div.table-body-cell',
103
+ table_header: 'div#resp-table-header',
104
+ header_column: 'div.table-header-cell'
105
+ }
106
+ custom_table.define_table_elements(table_spec)
107
+ end
108
+
109
+ def verify_page_ui
110
+ super
111
+
112
+ ui = {
113
+ country_select => {
114
+ exists: true,
115
+ visible: true,
116
+ enabled: true,
117
+ optioncount: 251
118
+ },
119
+ team_select => {
120
+ exists: true,
121
+ visible: true,
122
+ enabled: true,
123
+ optioncount: 32,
124
+ options: teams,
125
+ groupcount: 8,
126
+ group_headings: divisions
127
+ },
128
+ pork_check => {
129
+ exists: true,
130
+ visible: true,
131
+ enabled: true,
132
+ checked: true,
133
+ caption: 'Pork'
134
+ },
135
+ beef_check => {
136
+ exists: true,
137
+ visible: true,
138
+ enabled: true,
139
+ checked: false,
140
+ caption: 'Beef'
141
+ },
142
+ chicken_check => {
143
+ exists: true,
144
+ visible: true,
145
+ enabled: true,
146
+ checked: false,
147
+ caption: 'Chicken'
148
+ },
149
+ shrimp_check => {
150
+ exists: true,
151
+ visible: true,
152
+ enabled: true,
153
+ checked: false,
154
+ caption: 'Shrimp'
155
+ },
156
+ mild_radio => {
157
+ exists: true,
158
+ visible: true,
159
+ enabled: true,
160
+ selected: true,
161
+ caption: 'Mild'
162
+ },
163
+ spicey_radio => {
164
+ exists: true,
165
+ visible: true,
166
+ enabled: true,
167
+ selected: false,
168
+ caption: 'Spicey'
169
+ },
170
+ hot_radio => {
171
+ exists: true,
172
+ visible: true,
173
+ enabled: true,
174
+ selected: false,
175
+ caption: 'Hot'
176
+ },
177
+ flaming_radio => {
178
+ exists: true,
179
+ visible: true,
180
+ enabled: true,
181
+ selected: false,
182
+ caption: 'Flaming'
183
+ },
184
+ custom_table => {
185
+ visible: true,
186
+ columncount: 4,
187
+ rowcount: 3,
188
+ { row: 1 } => [['Cell 1–1', 'Cell 1–2', 'Cell 1–3', 'Cell 1–4']],
189
+ { row: 2 } => [['Cell 2–1', 'Cell 2–2', 'Cell 2–3', 'Cell 2–4']],
190
+ { row: 3 } => [['Cell 3–1', 'Cell 3–2', 'Cell 3–3', 'Cell 3–4']],
191
+ { cell: [1, 3] } => ['Cell 1–3'],
192
+ { cell: [2, 4] } => ['Cell 2–4'],
193
+ { column: 3 } => [['Cell 1–3', 'Cell 2–3', 'Cell 3–3']]
194
+ }
195
+ }
196
+ verify_ui_states(ui)
197
+ team_select.verify_options(teams)
198
+ end
199
+
200
+ def populate_form
201
+ @selected_country = countries.sample
202
+ @selected_team = teams.sample
203
+ @selected_checks = [:chicken, :shrimp]
204
+ @selected_radio = 3
205
+ fields = {
206
+ country_select => @selected_country,
207
+ team_select => @selected_team,
208
+ pork_check => @selected_checks.include?(:pork),
209
+ beef_check => @selected_checks.include?(:beef),
210
+ chicken_check => @selected_checks.include?(:chicken),
211
+ shrimp_check => @selected_checks.include?(:shrimp),
212
+ mild_radio => @selected_radio == 1,
213
+ spicey_radio => @selected_radio == 2,
214
+ hot_radio => @selected_radio == 3,
215
+ flaming_radio => @selected_radio == 4
216
+ }
217
+ populate_data_fields(fields)
218
+ end
219
+
220
+ def set_select_options
221
+ @selected_country = countries.sample
222
+ @selected_team = teams.sample
223
+ country_select.set(@selected_country)
224
+ team_select.set(@selected_team)
225
+ end
226
+
227
+ def verify_form_data
228
+ ui = {
229
+ country_select => { selected: @selected_country },
230
+ team_select => { selected: @selected_team },
231
+ pork_check => { checked: @selected_checks.include?(:pork) },
232
+ beef_check => { checked: @selected_checks.include?(:beef) },
233
+ chicken_check => { checked: @selected_checks.include?(:chicken) },
234
+ shrimp_check => { checked: @selected_checks.include?(:shrimp) },
235
+ mild_radio => { selected: @selected_radio == 1 },
236
+ spicey_radio => { selected: @selected_radio == 2 },
237
+ hot_radio => { selected: @selected_radio == 3 },
238
+ flaming_radio => { selected: @selected_radio == 4 }
239
+ }
240
+ verify_ui_states(ui)
241
+ end
242
+
243
+ def choose_options_by(method)
244
+ case method.downcase.to_sym
245
+ when :index
246
+ country_select.choose_option(index: 56)
247
+ team_select.choose_option(index: 20)
248
+ when :text
249
+ country_select.choose_option('Costa Rica')
250
+ team_select.choose_option('Seattle Seahawks')
251
+ else
252
+ raise "#{method} is not a valid selector"
253
+ end
254
+ end
255
+
256
+ def verify_chosen_options
257
+ ui = {
258
+ country_select => { selected: 'Costa Rica' },
259
+ team_select => { selected: 'Seattle Seahawks' }
260
+ }
261
+ verify_ui_states(ui)
262
+ end
263
+ end