testcentricity_web 4.1.6 → 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.
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
@@ -0,0 +1,67 @@
1
+ @!grid @!mobile
2
+
3
+
4
+ Feature: HTML5 Audio/Video Test Page using CSS locators
5
+ In order to ensure comprehensive support for HTML5 Audio and Video media elements
6
+ As a developer of the TestCentricity web gem
7
+ I expect to validate the interaction and verification capabilities of media UI elements
8
+
9
+
10
+ Background:
11
+ Given I am on the Media Test page
12
+
13
+
14
+ Scenario: Verify video player play and pause controls
15
+ When I play the video media
16
+ Then the video should be playing
17
+ When I pause the video media
18
+ Then the video should be paused
19
+
20
+
21
+ Scenario: Verify audio player play and pause controls
22
+ When I play the audio media
23
+ Then the audio should be playing
24
+ When I pause the audio media
25
+ Then the audio should be paused
26
+
27
+
28
+ Scenario: Verify video player mute control
29
+ When I mute the video media
30
+ Then the video should be muted
31
+ When I unmute the video media
32
+ Then the video should be unmuted
33
+
34
+
35
+ Scenario: Verify audio player mute control
36
+ When I mute the audio media
37
+ Then the audio should be muted
38
+ When I unmute the audio media
39
+ Then the audio should be unmuted
40
+
41
+
42
+ Scenario: Verify video player volume control
43
+ When I set the volume of the video to .5
44
+ Then the video should have a volume of .5
45
+
46
+
47
+ Scenario: Verify audio player volume control
48
+ When I set the volume of the audio to .5
49
+ Then the audio should have a volume of .5
50
+
51
+
52
+ Scenario: Verify video playback speed settings
53
+ When I play the video with a playback speed of 2x
54
+ Then the video should play at 2x speed
55
+ When I play the video with a playback speed of 0.5x
56
+ Then the video should play at 0.5x speed
57
+ When I play the video with a playback speed of 1x
58
+ Then the video should play at 1x speed
59
+
60
+
61
+ Scenario: Verify audio playback speed settings
62
+ When I play the audio with a playback speed of 2x
63
+ Then the audio should play at 2x speed
64
+ When I play the audio with a playback speed of 0.5x
65
+ Then the audio should play at 0.5x speed
66
+ When I play the audio with a playback speed of 1x
67
+ Then the audio should play at 1x speed
@@ -35,3 +35,90 @@ end
35
35
  Then(/^I expect the tab order to be correct$/) do
36
36
  PageManager.current_page.verify_tab_order
37
37
  end
38
+
39
+
40
+ When(/^I click the (.*) navigation (?:tab|link)$/) do |page_name|
41
+ # find and navigate to the specified target page
42
+ target_page = PageManager.find_page(page_name)
43
+ target_page.navigate_to
44
+ end
45
+
46
+
47
+ Then(/^I should (?:see|be on) the (.*) page$/) do |page_name|
48
+ # find and verify that the specified target page is loaded
49
+ target_page = PageManager.find_page(page_name)
50
+ target_page.verify_page_exists
51
+ end
52
+
53
+
54
+ Then(/^I expect the (.*) page to be correctly displayed in a new browser tab$/) do |page_name|
55
+ Browsers.switch_to_new_browser_instance
56
+ Environ.set_external_page(true)
57
+ TestCentricity::WebDriverConnect.initialize_browser_size if Environ.headless
58
+ # find and verify that the specified target page is loaded
59
+ target_page = PageManager.find_page(page_name)
60
+ target_page.verify_page_exists
61
+ # verify that target page is correctly displayed
62
+ target_page.verify_page_ui
63
+ end
64
+
65
+
66
+ When(/^I (?:access|switch to) the new browser tab$/) do
67
+ Browsers.switch_to_new_browser_instance
68
+ end
69
+
70
+
71
+ When(/^I close the current browser window$/) do
72
+ Browsers.close_current_browser_window
73
+ # intercept and accept any JavaScript system or browser modals that may appear
74
+ begin
75
+ page.driver.browser.switch_to.alert.accept
76
+ switch_to_new_browser_instance
77
+ rescue
78
+ end
79
+ end
80
+
81
+
82
+ When(/^I close the previous browser window$/) do
83
+ Browsers.close_old_browser_instance
84
+ end
85
+
86
+
87
+ When(/^I refresh the current page$/) do
88
+ Browsers.refresh_browser unless Environ.driver == :appium
89
+ end
90
+
91
+
92
+ When(/^I navigate back$/) do
93
+ Browsers.navigate_back
94
+ end
95
+
96
+
97
+ When(/^I navigate forward$/) do
98
+ Browsers.navigate_forward
99
+ end
100
+
101
+
102
+ When(/^I delete all cookies$/) do
103
+ Browsers.delete_all_cookies
104
+ end
105
+
106
+
107
+ When(/^I set device orientation to (.*)$/) do |orientation|
108
+ Browsers.set_device_orientation(orientation.downcase.to_sym)
109
+ end
110
+
111
+
112
+ When(/^I choose custom select options by typing$/) do
113
+ custom_controls_page.set_select_options
114
+ end
115
+
116
+
117
+ When(/^I choose selectlist options by (.*)$/) do |method|
118
+ PageManager.current_page.choose_options_by(method)
119
+ end
120
+
121
+
122
+ Then(/^I expect the selected option to be displayed$/) do
123
+ PageManager.current_page.verify_chosen_options
124
+ end
@@ -0,0 +1,30 @@
1
+
2
+
3
+ When(/^I (.*) the (.*) media$/) do |action, media_type|
4
+ media_test_page.perform_action(media_type, action)
5
+ end
6
+
7
+
8
+ Then(/^the (.*) should be (.*)$/) do |media_type, state|
9
+ media_test_page.verify_media_state(media_type, state)
10
+ end
11
+
12
+
13
+ When(/^I play the (.*) with a playback speed of (.*)x$/) do |media_type, rate|
14
+ media_test_page.set_playback_rate(media_type, rate)
15
+ end
16
+
17
+
18
+ Then(/^the (.*) should play at (.*)x speed$/) do |media_type, rate|
19
+ media_test_page.verify_playback_rate(media_type, rate)
20
+ end
21
+
22
+
23
+ When(/^I set the volume of the (.*) to (.*)$/) do |media_type, volume|
24
+ media_test_page.set_volume(media_type, volume)
25
+ end
26
+
27
+
28
+ Then(/^the (.*) should have a volume of (.*)$/) do |media_type, volume|
29
+ media_test_page.verify_volume(media_type, volume)
30
+ end
@@ -0,0 +1,43 @@
1
+ class FormDataSource < TestCentricity::ExcelDataSource
2
+ def read_form_data
3
+ form_data = case ENV['DATA_SOURCE'].downcase.to_sym
4
+ when :excel
5
+ read_excel_row_data('Form_data', 'primary')
6
+ when :yaml, :json
7
+ environs.read('Form_data', 'primary')
8
+ else
9
+ raise "#{ENV['DATA_SOURCE']} is not a valid data source"
10
+ end
11
+ FormData.current = FormData.new(form_data)
12
+ end
13
+
14
+ def map_form_data(form_data)
15
+ FormData.current = FormData.new(form_data)
16
+ end
17
+ end
18
+
19
+
20
+ class FormData < TestCentricity::DataPresenter
21
+ attribute :username, String
22
+ attribute :password, String
23
+ attribute :image_filename, String
24
+ attribute :multi_select, String
25
+ attribute :drop_down_item, String
26
+ attribute :check1, Boolean, default: false
27
+ attribute :check2, Boolean, default: false
28
+ attribute :check3, Boolean, default: false
29
+ attribute :radio_select, Integer
30
+
31
+ def initialize(data)
32
+ @username = data[:username]
33
+ @password = data[:password]
34
+ @image_filename = data[:image_filename]
35
+ @multi_select = data[:multi_select]
36
+ @drop_down_item = data[:drop_down_item]
37
+ @check1 = data[:check1]
38
+ @check2 = data[:check2]
39
+ @check3 = data[:check3]
40
+ @radio_select = data[:radio_select]
41
+ super
42
+ end
43
+ end
@@ -5,13 +5,16 @@ require 'require_all'
5
5
  require 'simplecov'
6
6
  require 'testcentricity_web'
7
7
 
8
- SimpleCov.command_name "features #{ENV['WEB_BROWSER']}" + (ENV['TEST_ENV_NUMBER'] || '')
8
+ include TestCentricity
9
9
 
10
- # require_relative 'world_data'
10
+ coverage_report_name = "Features-#{ENV['WEB_BROWSER']}-#{ENV['SELENIUM']}" + (ENV['TEST_ENV_NUMBER'] || '')
11
+ SimpleCov.command_name("#{coverage_report_name}-#{Time.now.strftime('%Y%m%d%H%M%S%L')}")
12
+
13
+ require_relative 'world_data'
11
14
  require_relative 'world_pages'
12
15
 
13
- # require_rel 'data'
14
- # require_rel 'sections'
16
+ require_rel 'data'
17
+ require_rel 'sections'
15
18
  require_rel 'pages'
16
19
 
17
20
  $LOAD_PATH << './lib'
@@ -27,9 +30,10 @@ I18n.locale = ENV['LOCALE']
27
30
  Faker::Config.locale = ENV['LOCALE']
28
31
 
29
32
  # instantiate all data objects and target test environment
30
- # include WorldData
31
- # environs.find_environ(ENV['TEST_ENVIRONMENT'], :yaml)
32
- # WorldData.instantiate_data_objects
33
+ include WorldData
34
+ ENV['DATA_SOURCE'] = 'yaml' unless ENV['DATA_SOURCE']
35
+ environs.find_environ(ENV['TEST_ENVIRONMENT'], ENV['DATA_SOURCE'].downcase.to_sym)
36
+ WorldData.instantiate_data_objects
33
37
 
34
38
  # instantiate all page objects
35
39
  include WorldPages
@@ -38,6 +42,10 @@ WorldPages.instantiate_page_objects
38
42
  # establish connection to WebDriver and target web browser
39
43
  Webdrivers.cache_time = 86_400
40
44
 
41
- options = { app_host: "file://#{File.dirname(__FILE__)}/../../test_site" }
42
- options = { app_host: "http://192.168.1.129"}
43
- TestCentricity::WebDriverConnect.initialize_web_driver(options)
45
+
46
+ url = if Environ.test_environment == :local
47
+ "file://#{File.dirname(__FILE__)}/../../test_site"
48
+ else
49
+ Environ.current.app_host
50
+ end
51
+ WebDriverConnect.initialize_web_driver(app_host: url)
@@ -104,6 +104,11 @@ Around('@!firefox') do |scenario, block|
104
104
  end
105
105
 
106
106
 
107
+ Around('@!firefox_headless') do |scenario, block|
108
+ qualify_browser(:firefox_headless, 'Firefox headless', scenario, block)
109
+ end
110
+
111
+
107
112
  # block feature/scenario execution if running against iPad mobile browser
108
113
  Around('@!ipad') do |scenario, block|
109
114
  qualify_device('ipad', scenario, block)
@@ -182,7 +187,27 @@ end
182
187
 
183
188
  Around('@!mobile') do |scenario, block|
184
189
  if Environ.platform == :mobile
185
- log "Scenario '#{scenario.name}' can not be executed on mobile devices or simulators."
190
+ log "Scenario '#{scenario.name}' is not executed on mobile devices or simulators."
191
+ skip_this_scenario
192
+ else
193
+ block.call
194
+ end
195
+ end
196
+
197
+
198
+ Around('@!headless') do |scenario, block|
199
+ if Environ.headless
200
+ log "Scenario '#{scenario.name}' is not executed on headless browsers."
201
+ skip_this_scenario
202
+ else
203
+ block.call
204
+ end
205
+ end
206
+
207
+
208
+ Around('@!firefox_grid') do |scenario, block|
209
+ if Environ.browser == :firefox && Environ.grid
210
+ log "Scenario '#{scenario.name}' can not be executed on grid hosted Firefox browsers."
186
211
  skip_this_scenario
187
212
  else
188
213
  block.call
@@ -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#header'
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
@@ -1,7 +1,7 @@
1
- # Page Object class definition for Basic HTML Test page with CSS locators
1
+ # Page Object class definition for Basic HTML Form page with CSS locators
2
2
 
3
- class BasicCSSTestPage < BasicTestPage
4
- trait(:page_name) { 'Basic CSS Test' }
3
+ class BasicCSSFormPage < BasicFormPage
4
+ trait(:page_name) { 'Basic CSS Form' }
5
5
  trait(:page_locator) { 'form#HTMLFormElements' }
6
6
 
7
7
  # Basic HTML Test page UI elements
@@ -12,8 +12,8 @@ class BasicCSSTestPage < BasicTestPage
12
12
  number_field: 'input#number-field',
13
13
  color_picker: 'input#color-picker',
14
14
  comments_field: 'textarea#comments'
15
- range :slider, 'input#slider'
16
- filefield :upload_file, 'input#filename'
15
+ ranges slider: 'input#slider'
16
+ filefields upload_file: 'input#filename'
17
17
  checkboxes check_1: 'input#check1',
18
18
  check_2: 'input#check2',
19
19
  check_3: 'input#check3',
@@ -24,14 +24,17 @@ class BasicCSSTestPage < BasicTestPage
24
24
  radio_4: 'input#radio4'
25
25
  selectlists multi_select: 'select#multipleselect',
26
26
  drop_down_select: 'select#dropdown'
27
- table :static_table, 'table#table'
27
+ lists links_list: 'ul#links_list'
28
+ links link_1: 'a#link1',
29
+ link_2: 'a#link2',
30
+ link_3: 'a#link3'
31
+ tables static_table: 'table#table'
28
32
  images image_1: 'img#image1',
29
33
  image_2: 'img#image2',
30
34
  image_3: 'img#image3'
31
35
  buttons cancel_button: 'input#cancel',
32
36
  submit_button: 'input#submit'
33
- labels header_label: 'h1',
34
- username_label: "label[for='username']",
37
+ labels username_label: "label[for='username']",
35
38
  password_label: "label[for='password']",
36
39
  max_length_label: "label[for='maxlength']",
37
40
  read_only_label: "label[for='readonly']",
@@ -44,6 +47,7 @@ class BasicCSSTestPage < BasicTestPage
44
47
  radios_label: 'label#radios',
45
48
  multiselect_label: "label[for='multipleselect']",
46
49
  dropdown_label: "label[for='dropdown']",
50
+ link_label: 'label#links',
47
51
  table_label: "label[for='table']",
48
52
  images_label: 'label#images'
49
53
  end