testcentricity_web 4.1.5 → 4.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -0
  3. data/.simplecov +9 -0
  4. data/CHANGELOG.md +44 -0
  5. data/Gemfile.lock +60 -2
  6. data/README.md +17 -7
  7. data/Rakefile +86 -1
  8. data/config/cucumber.yml +170 -0
  9. data/config/test_data/LOCAL_data.json +15 -0
  10. data/config/test_data/LOCAL_data.xls +0 -0
  11. data/config/test_data/LOCAL_data.yml +11 -0
  12. data/config/test_data/data.json +25 -0
  13. data/config/test_data/data.xls +0 -0
  14. data/config/test_data/data.yml +20 -0
  15. data/docker-compose-v3.yml +48 -0
  16. data/features/basic_form_page_css.feature +39 -0
  17. data/features/basic_form_page_xpath.feature +26 -0
  18. data/features/media_players.feature +84 -0
  19. data/features/step_definitions/generic_steps.rb.rb +109 -0
  20. data/features/step_definitions/media_steps.rb +30 -0
  21. data/features/support/data/form_data.rb +43 -0
  22. data/features/support/env.rb +50 -0
  23. data/features/support/hooks.rb +265 -0
  24. data/features/support/pages/base_test_page.rb +22 -0
  25. data/features/support/pages/basic_css_form_page.rb +52 -0
  26. data/features/support/pages/basic_form_page.rb +393 -0
  27. data/features/support/pages/basic_xpath_form_page.rb +53 -0
  28. data/features/support/pages/custom_controls_page.rb +13 -0
  29. data/features/support/pages/indexed_sections_page.rb +13 -0
  30. data/features/support/pages/media_test_page.rb +208 -0
  31. data/features/support/sections/header_nav.rb +39 -0
  32. data/features/support/world_data.rb +12 -0
  33. data/features/support/world_pages.rb +18 -0
  34. data/lib/testcentricity_web/appium_server.rb +5 -0
  35. data/lib/testcentricity_web/data_objects/data_objects_helper.rb +7 -0
  36. data/lib/testcentricity_web/data_objects/environment.rb +18 -0
  37. data/lib/testcentricity_web/data_objects/excel_helper.rb +60 -59
  38. data/lib/testcentricity_web/version.rb +1 -1
  39. data/lib/testcentricity_web/web_core/drag_drop_helper.rb +4 -0
  40. data/lib/testcentricity_web/web_core/page_object.rb +8 -8
  41. data/lib/testcentricity_web/web_core/page_objects_helper.rb +43 -8
  42. data/lib/testcentricity_web/web_core/page_section.rb +1 -16
  43. data/lib/testcentricity_web/web_core/webdriver_helper.rb +16 -0
  44. data/lib/testcentricity_web/web_elements/checkbox.rb +3 -4
  45. data/lib/testcentricity_web/web_elements/file_field.rb +9 -5
  46. data/lib/testcentricity_web/web_elements/image.rb +2 -1
  47. data/lib/testcentricity_web/web_elements/media.rb +45 -11
  48. data/lib/testcentricity_web/web_elements/radio.rb +5 -1
  49. data/lib/testcentricity_web/web_elements/select_list.rb +11 -3
  50. data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +33 -7
  51. data/lib/testcentricity_web/web_elements/video.rb +2 -2
  52. data/reports/.keep +1 -0
  53. data/test_site/basic_test_page.html +290 -0
  54. data/test_site/custom_controls_page.html +58 -0
  55. data/test_site/images/Granny.jpg +0 -0
  56. data/test_site/images/Wilder.jpg +0 -0
  57. data/test_site/images/You_Betcha.jpg +0 -0
  58. data/test_site/indexed_sections_page.html +58 -0
  59. data/test_site/media/MIB2-subtitles-pt-BR.vtt +49 -0
  60. data/test_site/media/MIB2.mp4 +0 -0
  61. data/test_site/media/MP4_small.mp4 +0 -0
  62. data/test_site/media/MPS_sample.mp3 +0 -0
  63. data/test_site/media/count_and_bars.mp4 +0 -0
  64. data/test_site/media_page.html +86 -0
  65. data/testcentricity_web.gemspec +5 -0
  66. metadata +131 -4
  67. data/test_site/test_page.html +0 -11
@@ -0,0 +1,22 @@
1
+ # Page Object class definition for Base Test page
2
+
3
+ class BaseTestPage < TestCentricity::PageObject
4
+ # Base Test page UI elements
5
+ label :header_label, 'h2'
6
+ sections header_nav: NavHeader
7
+
8
+ def navigate_to
9
+ navigator
10
+ end
11
+
12
+ def verify_page_ui
13
+ # verify page title and header
14
+ ui = {
15
+ self => { exists: true, secure: false, title: page_title },
16
+ header_label => { visible: true, caption: page_title }
17
+ }
18
+ verify_ui_states(ui)
19
+ # verify header navigation bar
20
+ header_nav.verify_nav_bar
21
+ end
22
+ end
@@ -0,0 +1,52 @@
1
+ # Page Object class definition for Basic HTML Form page with CSS locators
2
+
3
+ class BasicCSSFormPage < BasicFormPage
4
+ trait(:page_name) { 'Basic CSS Form' }
5
+ trait(:page_locator) { 'form#HTMLFormElements' }
6
+
7
+ # Basic HTML Test page UI elements
8
+ textfields username_field: 'input#username',
9
+ password_field: 'input#password',
10
+ max_length_field: 'input#maxlength',
11
+ read_only_field: 'input#readonly',
12
+ number_field: 'input#number-field',
13
+ color_picker: 'input#color-picker',
14
+ comments_field: 'textarea#comments'
15
+ ranges slider: 'input#slider'
16
+ filefields upload_file: 'input#filename'
17
+ checkboxes check_1: 'input#check1',
18
+ check_2: 'input#check2',
19
+ check_3: 'input#check3',
20
+ check_4: 'input#check4'
21
+ radios radio_1: 'input#radio1',
22
+ radio_2: 'input#radio2',
23
+ radio_3: 'input#radio3',
24
+ radio_4: 'input#radio4'
25
+ selectlists multi_select: 'select#multipleselect',
26
+ drop_down_select: 'select#dropdown'
27
+ links link_1: 'a#link1',
28
+ link_2: 'a#link2',
29
+ link_3: 'a#link3'
30
+ tables static_table: 'table#table'
31
+ images image_1: 'img#image1',
32
+ image_2: 'img#image2',
33
+ image_3: 'img#image3'
34
+ buttons cancel_button: 'input#cancel',
35
+ submit_button: 'input#submit'
36
+ labels username_label: "label[for='username']",
37
+ password_label: "label[for='password']",
38
+ max_length_label: "label[for='maxlength']",
39
+ read_only_label: "label[for='readonly']",
40
+ number_label: "label[for='number-field']",
41
+ color_label: "label[for='color-picker']",
42
+ slider_label: "label[for='slider']",
43
+ comments_label: "label[for='comments']",
44
+ filename_label: "label[for='filename']",
45
+ checkboxes_label: 'label#checkboxes',
46
+ radios_label: 'label#radios',
47
+ multiselect_label: "label[for='multipleselect']",
48
+ dropdown_label: "label[for='dropdown']",
49
+ link_label: 'label#links',
50
+ table_label: "label[for='table']",
51
+ images_label: 'label#images'
52
+ end
@@ -0,0 +1,393 @@
1
+ # Page Object class definition for Basic HTML Form page
2
+
3
+ class BasicFormPage < BaseTestPage
4
+ trait(:page_url) { '/basic_test_page.html' }
5
+ trait(:navigator) { header_nav.open_form_page }
6
+ trait(:page_title) { 'Basic HTML Form'}
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) {
39
+ [
40
+ username_field,
41
+ password_field,
42
+ max_length_field,
43
+ read_only_field,
44
+ number_field,
45
+ color_picker,
46
+ slider,
47
+ comments_field,
48
+ upload_file,
49
+ check_1,
50
+ check_2,
51
+ check_3,
52
+ radio_1,
53
+ [
54
+ radio_2,
55
+ radio_3
56
+ ],
57
+ multi_select,
58
+ drop_down_select,
59
+ cancel_button,
60
+ submit_button
61
+ ]
62
+ }
63
+ trait(:safari_tab_order) {
64
+ [
65
+ username_field,
66
+ password_field,
67
+ max_length_field,
68
+ read_only_field,
69
+ number_field,
70
+ comments_field,
71
+ multi_select,
72
+ drop_down_select
73
+ ]
74
+ }
75
+
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?
82
+ ui = {
83
+ username_label => { visible: true, caption: 'Username:' },
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
+ },
97
+ password_label => { visible: true, caption: '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
+ },
109
+ max_length_label => { visible: true, caption: 'Max Length:' },
110
+ max_length_field => {
111
+ visible: true,
112
+ obscured: false,
113
+ enabled: true,
114
+ focused: false,
115
+ placeholder: 'up to 64 characters',
116
+ value: '',
117
+ maxlength: 64
118
+ },
119
+ read_only_label => { visible: true, caption: 'Read Only:' },
120
+ read_only_field => {
121
+ visible: true,
122
+ enabled: true,
123
+ readonly: true,
124
+ value: 'I am a read only text field'
125
+ },
126
+ number_label => { visible: true, caption: 'Number:' },
127
+ number_field => {
128
+ visible: true,
129
+ enabled: true,
130
+ value: '41',
131
+ min: 10,
132
+ max: 1024,
133
+ step: 1
134
+ },
135
+ color_label => { visible: true, caption: 'Color:' },
136
+ color_picker => { visible: true, enabled: true, value: '#000000' },
137
+ slider_label => { visible: true, caption: 'Range:' },
138
+ slider => {
139
+ visible: true,
140
+ enabled: true,
141
+ value: 25,
142
+ min: 0,
143
+ max: 50,
144
+ },
145
+ comments_label => { visible: true, caption: 'TextArea:' },
146
+ comments_field => { visible: true, enabled: true, value: '' },
147
+ filename_label => { visible: true, caption: 'Filename:' },
148
+ upload_file => { visible: true, enabled: true, value: '' },
149
+ checkboxes_label => { visible: true, caption: 'Checkbox Items:' },
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
+ },
186
+ radios_label => { visible: true, caption: 'Radio Items:' },
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
+ },
219
+ multiselect_label => { visible: true, caption: 'Multiple Select Values:' },
220
+ multi_select => {
221
+ visible: true,
222
+ enabled: true,
223
+ optioncount: 4,
224
+ options: ['Selection Item 1', 'Selection Item 2', 'Selection Item 3', 'Selection Item 4'],
225
+ selected: ''
226
+ },
227
+ dropdown_label => { visible: true, caption: 'Dropdown:' },
228
+ drop_down_select => {
229
+ visible: true,
230
+ enabled: true,
231
+ optioncount: 6,
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'],
233
+ selected: 'Drop Down Item 1'
234
+ },
235
+ link_label => { visible: true, caption: 'Links:' },
236
+ link_1 => {
237
+ visible: true,
238
+ href: { ends_with: 'media_page.html' },
239
+ caption: 'Open Media Page in same window/tab'
240
+ },
241
+ link_2 => {
242
+ visible: true,
243
+ href: { ends_with: 'media_page.html' },
244
+ caption: 'Open Media Page in a new window/tab'
245
+ },
246
+ link_3 => {
247
+ visible: true,
248
+ aria_disabled: true,
249
+ role: 'link',
250
+ caption: 'Disabled Link'
251
+ },
252
+ table_label => { visible: true, caption: 'Table:' },
253
+ static_table => {
254
+ visible: true,
255
+ columncount: 3,
256
+ rowcount: 4,
257
+ column_headers: %w[Company Contact Country],
258
+ { row: 1 } => [['Alfreds Futterkiste', 'Maria Anders', 'Germany']],
259
+ { row: 2 } => [['Centro comercial Moctezuma', 'Francisco Chang', 'Mexico']],
260
+ { row: 3 } => [['Ernst Handel', 'Roland Mendel', 'Austria']],
261
+ { row: 4 } => [['Island Trading', 'Helen Bennett', 'UK']],
262
+ { cell: [1, 3] } => ['Germany'],
263
+ { cell: [2, 3] } => ['Mexico'],
264
+ { column: 3 } => [['Germany', 'Mexico', 'Austria', 'UK']]
265
+ },
266
+ images_label => { visible: true, caption: 'Images:' },
267
+ image_1 => {
268
+ visible: true,
269
+ loaded: true,
270
+ broken: false,
271
+ src: { ends_with: 'images/Wilder.jpg' },
272
+ alt: "It's alive"
273
+ },
274
+ image_2 => {
275
+ visible: true,
276
+ loaded: true,
277
+ broken: false,
278
+ src: { ends_with: 'images/You_Betcha.jpg' },
279
+ alt: 'You Betcha'
280
+ },
281
+ image_3 => {
282
+ visible: true,
283
+ broken: true,
284
+ src: { ends_with: 'wrongname.gif' },
285
+ alt: 'A broken image'
286
+ },
287
+ cancel_button => { visible: true, enabled: true, caption: 'Cancel' },
288
+ submit_button => { visible: true, enabled: true, caption: 'Submit' }
289
+ }
290
+ verify_ui_states(ui)
291
+ end
292
+
293
+ def form_data
294
+ data = form_data_source.read_form_data
295
+
296
+ if Environ.platform == :mobile
297
+ file_path = nil
298
+ file_name = ''
299
+ color_value = '#000000'
300
+ else
301
+ file_path = "#{Dir.pwd}/test_site/images/#{data.image_filename}"
302
+ file_name = data.image_filename
303
+ color_value = Faker::Color.hex_color
304
+ end
305
+ {
306
+ username: data.username,
307
+ password: data.password,
308
+ maxlength: Faker::Marketing.buzzwords,
309
+ number: Faker::Number.between(from: 10, to: 1024),
310
+ color: color_value,
311
+ slider: 50,
312
+ comments: Faker::Hipster.paragraph,
313
+ filepath: file_path,
314
+ filename: file_name,
315
+ check1: data.check1,
316
+ check2: data.check2,
317
+ check3: data.check3,
318
+ radio1: false,
319
+ radio2: true,
320
+ radio3: false,
321
+ multi_select: data.multi_select,
322
+ drop_select: data.drop_down_item
323
+ }
324
+ end
325
+
326
+ def populate_form
327
+ @data = form_data
328
+ fields = {
329
+ username_field => @data[:username],
330
+ password_field => @data[:password],
331
+ max_length_field => @data[:maxlength],
332
+ number_field => @data[:number],
333
+ color_picker => @data[:color],
334
+ slider => @data[:slider],
335
+ comments_field => @data[:comments],
336
+ upload_file => @data[:filepath],
337
+ check_1 => @data[:check1],
338
+ check_2 => @data[:check2],
339
+ check_3 => @data[:check3],
340
+ radio_1 => @data[:radio1],
341
+ radio_2 => @data[:radio2],
342
+ radio_3 => @data[:radio3],
343
+ multi_select => @data[:multi_select],
344
+ drop_down_select => @data[:drop_select]
345
+ }
346
+ populate_data_fields(fields)
347
+ end
348
+
349
+ def verify_form_data
350
+ ui = {
351
+ username_field => { value: @data[:username] },
352
+ password_field => { value: @data[:password] },
353
+ max_length_field => { value: @data[:maxlength] },
354
+ number_field => { value: @data[:number].to_s },
355
+ color_picker => { value: @data[:color] },
356
+ slider => { value: @data[:slider] },
357
+ comments_field => { value: @data[:comments] },
358
+ upload_file => { value: { ends_with: @data[:filename] } },
359
+ check_1 => { checked: @data[:check1] },
360
+ check_2 => { checked: @data[:check2] },
361
+ check_3 => { checked: @data[:check3] },
362
+ radio_1 => { selected: @data[:radio1] },
363
+ radio_2 => { selected: @data[:radio2] },
364
+ radio_3 => { selected: @data[:radio3] },
365
+ multi_select => { selected: @data[:multi_select] },
366
+ drop_down_select => { selected: @data[:drop_select] }
367
+ }
368
+ verify_ui_states(ui)
369
+ end
370
+
371
+ def perform_action(action)
372
+ case action
373
+ when :submit
374
+ submit_button.click
375
+ when :cancel
376
+ cancel_button.click
377
+ else
378
+ raise "#{action} is not a valid selector"
379
+ end
380
+ end
381
+
382
+ def verify_tab_order
383
+ order = case Environ.browser
384
+ when :safari
385
+ safari_tab_order
386
+ when :firefox
387
+ firefox_order
388
+ else
389
+ tab_order
390
+ end
391
+ verify_focus_order(order)
392
+ end
393
+ end
@@ -0,0 +1,53 @@
1
+ # Page Object class definition for Basic HTML Form page with Xpath locators
2
+
3
+ class BasicXpathFormPage < BasicFormPage
4
+ trait(:page_name) { 'Basic Xpath Form' }
5
+ trait(:page_locator) { "//form[@id='HTMLFormElements']" }
6
+
7
+ # Basic HTML Test page UI elements
8
+ textfields username_field: "//input[@id='username']",
9
+ password_field: "//input[@id='password']",
10
+ max_length_field: "//input[@id='maxlength']",
11
+ read_only_field: "//input[@id='readonly']",
12
+ number_field: "//input[@id='number-field']",
13
+ comments_field: "//textarea[@id='comments']",
14
+ color_picker: "//input[@id='color-picker']"
15
+ ranges slider: "//input[@id='slider']"
16
+ filefields upload_file: "//input[@id='filename']"
17
+ checkboxes check_1: "//input[@id='check1']",
18
+ check_2: "//input[@id='check2']",
19
+ check_3: "//input[@id='check3']",
20
+ check_4: "//input[@id='check4']"
21
+ radios radio_1: "//input[@id='radio1']",
22
+ radio_2: "//input[@id='radio2']",
23
+ radio_3: "//input[@id='radio3']",
24
+ radio_4: "//input[@id='radio4']"
25
+ selectlists multi_select: "//select[@id='multipleselect']",
26
+ drop_down_select: "//select[@id='dropdown']"
27
+ links link_1: "//a[@id='link1']",
28
+ link_2: "//a[@id='link2']",
29
+ link_3: "//a[@id='link3']"
30
+ tables static_table: "//table[@id='table']"
31
+ images image_1: "//img[@id='image1']",
32
+ image_2: "//img[@id='image2']",
33
+ image_3: "//img[@id='image3']"
34
+ buttons cancel_button: "//input[@id='cancel']",
35
+ submit_button: "//input[@id='submit']"
36
+ labels header_label: '//h2',
37
+ username_label: "//label[@for='username']",
38
+ password_label: "//label[@for='password']",
39
+ max_length_label: "//label[@for='maxlength']",
40
+ read_only_label: "//label[@for='readonly']",
41
+ number_label: "//label[@for='number-field']",
42
+ color_label: "//label[@for='color-picker']",
43
+ slider_label: "//label[@for='slider']",
44
+ comments_label: "//label[@for='comments']",
45
+ filename_label: "//label[@for='filename']",
46
+ checkboxes_label: "//label[@id='checkboxes']",
47
+ radios_label: "//label[@id='radios']",
48
+ multiselect_label: "//label[@for='multipleselect']",
49
+ dropdown_label: "//label[@for='dropdown']",
50
+ link_label: "//label[@id='links']",
51
+ table_label: "//label[@for='table']",
52
+ images_label: "//label[@id='images']"
53
+ end
@@ -0,0 +1,13 @@
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
+
10
+ def verify_page_ui
11
+ super
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # Page Object class definition for Indexed Sections page with CSS locators
2
+
3
+ class IndexedSectionsPage < BaseTestPage
4
+ trait(:page_name) { 'Indexed Sections' }
5
+ trait(:page_locator) { 'div.indexed-sections-page-body' }
6
+ trait(:page_url) { '/indexed_sections_page.html' }
7
+ trait(:navigator) { header_nav.open_indexed_sections_page }
8
+ trait(:page_title) { 'Indexed Sections Page'}
9
+
10
+ def verify_page_ui
11
+ super
12
+ end
13
+ end