testcentricity_web 4.1.9 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +96 -1
  3. data/README.md +88 -48
  4. data/lib/testcentricity_web/browser_helper.rb +2 -1
  5. data/lib/testcentricity_web/data_objects/environment.rb +0 -1
  6. data/lib/testcentricity_web/version.rb +1 -1
  7. data/lib/testcentricity_web/web_core/page_objects_helper.rb +40 -3
  8. data/lib/testcentricity_web/web_core/webdriver_helper.rb +89 -80
  9. data/lib/testcentricity_web/web_elements/media.rb +108 -0
  10. data/lib/testcentricity_web/web_elements/textfield.rb +28 -0
  11. data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +39 -1
  12. metadata +37 -181
  13. data/.gitignore +0 -39
  14. data/.idea/.name +0 -1
  15. data/.idea/encodings.xml +0 -6
  16. data/.idea/misc.xml +0 -4
  17. data/.idea/modules.xml +0 -8
  18. data/.idea/vcs.xml +0 -7
  19. data/.rspec +0 -4
  20. data/.rubocop.yml +0 -38
  21. data/.ruby-version +0 -1
  22. data/.simplecov +0 -9
  23. data/CODE_OF_CONDUCT.md +0 -13
  24. data/Gemfile +0 -6
  25. data/Rakefile +0 -115
  26. data/config/cucumber.yml +0 -171
  27. data/config/locales/en-US.yml +0 -56
  28. data/config/test_data/LOCAL_data.json +0 -15
  29. data/config/test_data/LOCAL_data.xls +0 -0
  30. data/config/test_data/LOCAL_data.yml +0 -11
  31. data/config/test_data/data.json +0 -25
  32. data/config/test_data/data.xls +0 -0
  33. data/config/test_data/data.yml +0 -20
  34. data/docker-compose.yml +0 -48
  35. data/features/basic_form_page_css.feature +0 -54
  36. data/features/basic_form_page_xpath.feature +0 -26
  37. data/features/custom_controls.feature +0 -29
  38. data/features/media_players.feature +0 -67
  39. data/features/step_definitions/generic_steps.rb.rb +0 -124
  40. data/features/step_definitions/media_steps.rb +0 -30
  41. data/features/support/data/form_data.rb +0 -43
  42. data/features/support/env.rb +0 -51
  43. data/features/support/hooks.rb +0 -270
  44. data/features/support/pages/base_test_page.rb +0 -22
  45. data/features/support/pages/basic_css_form_page.rb +0 -53
  46. data/features/support/pages/basic_form_page.rb +0 -429
  47. data/features/support/pages/basic_xpath_form_page.rb +0 -54
  48. data/features/support/pages/custom_controls_page.rb +0 -263
  49. data/features/support/pages/indexed_sections_page.rb +0 -57
  50. data/features/support/pages/media_test_page.rb +0 -207
  51. data/features/support/sections/header_nav.rb +0 -48
  52. data/features/support/sections/product_card.rb +0 -39
  53. data/features/support/world_data.rb +0 -12
  54. data/features/support/world_pages.rb +0 -18
  55. data/reports/.keep +0 -1
  56. data/spec/fixtures/page_object.rb +0 -22
  57. data/spec/fixtures/section_object.rb +0 -21
  58. data/spec/spec_helper.rb +0 -31
  59. data/spec/testcentricity_web/browser_spec.rb +0 -41
  60. data/spec/testcentricity_web/elements/audio_spec.rb +0 -68
  61. data/spec/testcentricity_web/elements/button_spec.rb +0 -18
  62. data/spec/testcentricity_web/elements/checkbox_spec.rb +0 -33
  63. data/spec/testcentricity_web/elements/file_field_spec.rb +0 -13
  64. data/spec/testcentricity_web/elements/image_spec.rb +0 -33
  65. data/spec/testcentricity_web/elements/label_spec.rb +0 -18
  66. data/spec/testcentricity_web/elements/link_spec.rb +0 -23
  67. data/spec/testcentricity_web/elements/list_spec.rb +0 -13
  68. data/spec/testcentricity_web/elements/radio_spec.rb +0 -28
  69. data/spec/testcentricity_web/elements/ui_element_spec.rb +0 -125
  70. data/spec/testcentricity_web/elements/video_spec.rb +0 -68
  71. data/spec/testcentricity_web/helper_specs/object_helpers_spec.rb +0 -39
  72. data/spec/testcentricity_web/helper_specs/string_helpers_spec.rb +0 -49
  73. data/spec/testcentricity_web/page_object_spec.rb +0 -90
  74. data/spec/testcentricity_web/section_object_spec.rb +0 -72
  75. data/spec/testcentricity_web/version_spec.rb +0 -7
  76. data/spec/testcentricity_web/webdriver_connect/grid_webdriver_spec.rb +0 -72
  77. data/spec/testcentricity_web/webdriver_connect/local_webdriver_spec.rb +0 -86
  78. data/spec/testcentricity_web/webdriver_connect/mobile_webdriver_spec.rb +0 -65
  79. data/test_site/basic_test_page.html +0 -290
  80. data/test_site/chosen-sprite.png +0 -0
  81. data/test_site/chosen-sprite@2x.png +0 -0
  82. data/test_site/chosen.css +0 -496
  83. data/test_site/chosen.jquery.js +0 -1359
  84. data/test_site/chosen.jquery.min.js +0 -3
  85. data/test_site/chosen.min.css +0 -11
  86. data/test_site/chosen.proto.js +0 -1399
  87. data/test_site/chosen.proto.min.js +0 -3
  88. data/test_site/composer.json +0 -36
  89. data/test_site/custom_controls_page.html +0 -629
  90. data/test_site/docsupport/chosen.png +0 -0
  91. data/test_site/docsupport/init.js +0 -11
  92. data/test_site/docsupport/init.proto.js +0 -16
  93. data/test_site/docsupport/jquery-1.12.4.min.js +0 -5
  94. data/test_site/docsupport/jquery-3.2.1.min.js +0 -4
  95. data/test_site/docsupport/oss-credit.png +0 -0
  96. data/test_site/docsupport/prism.css +0 -108
  97. data/test_site/docsupport/prism.js +0 -9
  98. data/test_site/docsupport/prototype-1.7.0.0.js +0 -6082
  99. data/test_site/docsupport/style.css +0 -219
  100. data/test_site/images/Blouse_Black.jpg +0 -0
  101. data/test_site/images/Granny.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/Wilder.jpg +0 -0
  105. data/test_site/images/You_Betcha.jpg +0 -0
  106. data/test_site/images/jeans3.jpg +0 -0
  107. data/test_site/indexed_sections_page.html +0 -215
  108. data/test_site/media/MIB2-subtitles-pt-BR.vtt +0 -49
  109. data/test_site/media/MIB2.mp4 +0 -0
  110. data/test_site/media/MP4_small.mp4 +0 -0
  111. data/test_site/media/MPS_sample.mp3 +0 -0
  112. data/test_site/media/bbc_scotland_report.mp3 +0 -0
  113. data/test_site/media/count_and_bars.mp4 +0 -0
  114. data/test_site/media_page.html +0 -86
  115. data/testcentricity_web.gemspec +0 -57
@@ -24,16 +24,23 @@ module TestCentricity
24
24
  @endpoint = options[:endpoint] if options.key?(:endpoint)
25
25
  @capabilities = options[:desired_capabilities] if options.key?(:desired_capabilities)
26
26
  end
27
-
28
- browser = ENV['WEB_BROWSER']
27
+ # determine browser type and driver
28
+ Environ.browser = ENV['WEB_BROWSER'] if ENV['WEB_BROWSER']
29
+ Environ.driver = if ENV['DRIVER']
30
+ ENV['DRIVER'].downcase.to_sym
31
+ else
32
+ :webdriver
33
+ end
29
34
  # set downloads folder path
30
35
  @downloads_path = "#{Dir.pwd}/downloads"
31
36
  if ENV['PARALLEL']
32
37
  # :nocov:
33
38
  Environ.parallel = true
34
39
  Environ.process_num = ENV['TEST_ENV_NUMBER']
35
- @downloads_path = "#{@downloads_path}/#{ENV['TEST_ENV_NUMBER']}"
36
- Dir.mkdir(@downloads_path) unless Dir.exist?(@downloads_path)
40
+ if Dir.exist?(@downloads_path)
41
+ @downloads_path = "#{@downloads_path}/#{ENV['TEST_ENV_NUMBER']}"
42
+ Dir.mkdir(@downloads_path) unless Dir.exist?(@downloads_path)
43
+ end
37
44
  # :nocov:
38
45
  else
39
46
  Environ.parallel = false
@@ -41,18 +48,16 @@ module TestCentricity
41
48
  @downloads_path = @downloads_path.tr('/', "\\") if OS.windows?
42
49
 
43
50
  # assume that we're testing within a local desktop web browser
44
- Environ.driver = :webdriver
45
51
  Environ.platform = :desktop
46
- Environ.browser = browser
47
52
  Environ.headless = false
48
53
  Environ.device = :web
49
54
  Environ.device_name = 'browser'
50
55
 
51
- context = case browser.downcase.to_sym
56
+ context = case Environ.driver
52
57
  when :appium
53
58
  initialize_appium
54
59
  'Appium'
55
- # :nocov:
60
+ # :nocov:
56
61
  when :browserstack
57
62
  initialize_browserstack
58
63
  'Browserstack cloud service'
@@ -65,8 +70,7 @@ module TestCentricity
65
70
  when :testingbot
66
71
  initialize_testingbot
67
72
  'TestingBot cloud service'
68
- # :nocov:
69
- else
73
+ when :webdriver
70
74
  if ENV['SELENIUM'] == 'remote'
71
75
  initialize_remote
72
76
  'Selenium Grid'
@@ -138,70 +142,75 @@ module TestCentricity
138
142
  private
139
143
 
140
144
  def self.initialize_appium
141
- Environ.platform = :mobile
145
+ Environ.platform = :mobile
146
+ Environ.device = :simulator
147
+ Environ.browser = ENV['APP_BROWSER']
142
148
  Environ.device_name = ENV['APP_DEVICE']
143
- Environ.device_os = ENV['APP_PLATFORM_NAME'].downcase.to_sym
149
+ Environ.device_os = ENV['APP_PLATFORM_NAME'].downcase.to_sym
144
150
  Environ.device_type = ENV['DEVICE_TYPE'] if ENV['DEVICE_TYPE']
145
151
  Environ.device_os_version = ENV['APP_VERSION']
146
152
  Environ.device_orientation = ENV['ORIENTATION'] if ENV['ORIENTATION']
147
153
  Capybara.default_driver = :appium
148
154
  Environ.driver = :appium
149
- desired_capabilities = {
150
- platformName: Environ.device_os,
151
- platformVersion: Environ.device_os_version,
152
- browserName: ENV['APP_BROWSER'],
153
- deviceName: Environ.device_name
154
- }
155
- desired_capabilities[:avd] = ENV['APP_DEVICE'] if Environ.device_os == :android
156
- desired_capabilities[:automationName] = ENV['AUTOMATION_ENGINE'] if ENV['AUTOMATION_ENGINE']
157
- if ENV['UDID']
158
- # :nocov:
159
- Environ.device = :device
160
- desired_capabilities[:udid] = ENV['UDID']
161
- desired_capabilities[:xcodeOrgId] = ENV['TEAM_ID'] if ENV['TEAM_ID']
162
- desired_capabilities[:xcodeSigningId] = ENV['TEAM_NAME'] if ENV['TEAM_NAME']
163
- # :nocov:
164
- else
165
- Environ.device = :simulator
166
- desired_capabilities[:orientation] = Environ.device_orientation.upcase if Environ.device_orientation
167
- if Environ.device_os == :ios
168
- desired_capabilities[:language] = Environ.language if Environ.language
169
- desired_capabilities[:locale] = Environ.locale.gsub('-', '_') if Environ.locale
170
- end
171
- end
172
- desired_capabilities[:safariIgnoreFraudWarning] = ENV['APP_IGNORE_FRAUD_WARNING'] if ENV['APP_IGNORE_FRAUD_WARNING']
173
- desired_capabilities[:safariInitialUrl] = ENV['APP_INITIAL_URL'] if ENV['APP_INITIAL_URL']
174
- desired_capabilities[:safariAllowPopups] = ENV['APP_ALLOW_POPUPS'] if ENV['APP_ALLOW_POPUPS']
175
- desired_capabilities[:shutdownOtherSimulators] = ENV['SHUTDOWN_OTHER_SIMS'] if ENV['SHUTDOWN_OTHER_SIMS']
176
- desired_capabilities[:forceSimulatorSoftwareKeyboardPresence] = ENV['SHOW_SIM_KEYBOARD'] if ENV['SHOW_SIM_KEYBOARD']
177
-
178
- desired_capabilities[:autoAcceptAlerts] = ENV['AUTO_ACCEPT_ALERTS'] if ENV['AUTO_ACCEPT_ALERTS']
179
- desired_capabilities[:autoDismissAlerts] = ENV['AUTO_DISMISS_ALERTS'] if ENV['AUTO_DISMISS_ALERTS']
180
- desired_capabilities[:isHeadless] = ENV['HEADLESS'] if ENV['HEADLESS']
181
-
182
- desired_capabilities[:newCommandTimeout] = ENV['NEW_COMMAND_TIMEOUT'] if ENV['NEW_COMMAND_TIMEOUT']
183
- desired_capabilities[:noReset] = ENV['APP_NO_RESET'] if ENV['APP_NO_RESET']
184
- desired_capabilities[:fullReset] = ENV['APP_FULL_RESET'] if ENV['APP_FULL_RESET']
185
- desired_capabilities[:webkitDebugProxyPort] = ENV['WEBKIT_DEBUG_PROXY_PORT'] if ENV['WEBKIT_DEBUG_PROXY_PORT']
186
- desired_capabilities[:webDriverAgentUrl] = ENV['WEBDRIVER_AGENT_URL'] if ENV['WEBDRIVER_AGENT_URL']
187
- desired_capabilities[:usePrebuiltWDA] = ENV['USE_PREBUILT_WDA'] if ENV['USE_PREBUILT_WDA']
188
- desired_capabilities[:useNewWDA] = ENV['USE_NEW_WDA'] if ENV['USE_NEW_WDA']
189
- desired_capabilities[:chromedriverExecutable] = ENV['CHROMEDRIVER_EXECUTABLE'] if ENV['CHROMEDRIVER_EXECUTABLE']
190
- # set wdaLocalPort (iOS) or systemPort (Android) if PARALLEL_PORT is true
191
- if ENV['PARALLEL'] && ENV['PARALLEL_PORT']
192
- # :nocov:
193
- if Environ.device_os == :ios
194
- desired_capabilities[:wdaLocalPort] = 8100 + ENV['TEST_ENV_NUMBER'].to_i
195
- else
196
- desired_capabilities[:systemPort] = 8200 + ENV['TEST_ENV_NUMBER'].to_i
197
- end
198
- # :nocov:
199
- else
200
- desired_capabilities[:wdaLocalPort] = ENV['WDA_LOCAL_PORT'] if ENV['WDA_LOCAL_PORT']
201
- desired_capabilities[:systemPort] = ENV['SYSTEM_PORT'] if ENV['SYSTEM_PORT']
202
- end
203
-
204
- desired_capabilities = @capabilities unless @capabilities.nil?
155
+ # define capabilites
156
+ desired_capabilities = if @capabilities.nil?
157
+ desired_capabilities = {
158
+ platformName: Environ.device_os,
159
+ platformVersion: Environ.device_os_version,
160
+ browserName: Environ.browser,
161
+ deviceName: Environ.device_name
162
+ }
163
+ desired_capabilities[:avd] = ENV['APP_DEVICE'] if Environ.device_os == :android
164
+ desired_capabilities[:automationName] = ENV['AUTOMATION_ENGINE'] if ENV['AUTOMATION_ENGINE']
165
+ if ENV['UDID']
166
+ # :nocov:
167
+ Environ.device = :device
168
+ desired_capabilities[:udid] = ENV['UDID']
169
+ desired_capabilities[:xcodeOrgId] = ENV['TEAM_ID'] if ENV['TEAM_ID']
170
+ desired_capabilities[:xcodeSigningId] = ENV['TEAM_NAME'] if ENV['TEAM_NAME']
171
+ # :nocov:
172
+ else
173
+ desired_capabilities[:orientation] = Environ.device_orientation.upcase if Environ.device_orientation
174
+ if Environ.device_os == :ios
175
+ desired_capabilities[:language] = Environ.language if Environ.language
176
+ desired_capabilities[:locale] = Environ.locale.gsub('-', '_') if Environ.locale
177
+ end
178
+ end
179
+ desired_capabilities[:safariIgnoreFraudWarning] = ENV['APP_IGNORE_FRAUD_WARNING'] if ENV['APP_IGNORE_FRAUD_WARNING']
180
+ desired_capabilities[:safariInitialUrl] = ENV['APP_INITIAL_URL'] if ENV['APP_INITIAL_URL']
181
+ desired_capabilities[:safariAllowPopups] = ENV['APP_ALLOW_POPUPS'] if ENV['APP_ALLOW_POPUPS']
182
+ desired_capabilities[:shutdownOtherSimulators] = ENV['SHUTDOWN_OTHER_SIMS'] if ENV['SHUTDOWN_OTHER_SIMS']
183
+ desired_capabilities[:forceSimulatorSoftwareKeyboardPresence] = ENV['SHOW_SIM_KEYBOARD'] if ENV['SHOW_SIM_KEYBOARD']
184
+
185
+ desired_capabilities[:autoAcceptAlerts] = ENV['AUTO_ACCEPT_ALERTS'] if ENV['AUTO_ACCEPT_ALERTS']
186
+ desired_capabilities[:autoDismissAlerts] = ENV['AUTO_DISMISS_ALERTS'] if ENV['AUTO_DISMISS_ALERTS']
187
+ desired_capabilities[:isHeadless] = ENV['HEADLESS'] if ENV['HEADLESS']
188
+
189
+ desired_capabilities[:newCommandTimeout] = ENV['NEW_COMMAND_TIMEOUT'] if ENV['NEW_COMMAND_TIMEOUT']
190
+ desired_capabilities[:noReset] = ENV['APP_NO_RESET'] if ENV['APP_NO_RESET']
191
+ desired_capabilities[:fullReset] = ENV['APP_FULL_RESET'] if ENV['APP_FULL_RESET']
192
+ desired_capabilities[:webkitDebugProxyPort] = ENV['WEBKIT_DEBUG_PROXY_PORT'] if ENV['WEBKIT_DEBUG_PROXY_PORT']
193
+ desired_capabilities[:webDriverAgentUrl] = ENV['WEBDRIVER_AGENT_URL'] if ENV['WEBDRIVER_AGENT_URL']
194
+ desired_capabilities[:usePrebuiltWDA] = ENV['USE_PREBUILT_WDA'] if ENV['USE_PREBUILT_WDA']
195
+ desired_capabilities[:useNewWDA] = ENV['USE_NEW_WDA'] if ENV['USE_NEW_WDA']
196
+ desired_capabilities[:chromedriverExecutable] = ENV['CHROMEDRIVER_EXECUTABLE'] if ENV['CHROMEDRIVER_EXECUTABLE']
197
+ # set wdaLocalPort (iOS) or systemPort (Android) if PARALLEL_PORT is true
198
+ if ENV['PARALLEL'] && ENV['PARALLEL_PORT']
199
+ # :nocov:
200
+ if Environ.device_os == :ios
201
+ desired_capabilities[:wdaLocalPort] = 8100 + ENV['TEST_ENV_NUMBER'].to_i
202
+ else
203
+ desired_capabilities[:systemPort] = 8200 + ENV['TEST_ENV_NUMBER'].to_i
204
+ end
205
+ # :nocov:
206
+ else
207
+ desired_capabilities[:wdaLocalPort] = ENV['WDA_LOCAL_PORT'] if ENV['WDA_LOCAL_PORT']
208
+ desired_capabilities[:systemPort] = ENV['SYSTEM_PORT'] if ENV['SYSTEM_PORT']
209
+ end
210
+ desired_capabilities
211
+ else
212
+ @capabilities
213
+ end
205
214
  # specify endpoint url
206
215
  @endpoint = 'http://localhost:4723/wd/hub' if @endpoint.nil?
207
216
 
@@ -225,7 +234,7 @@ module TestCentricity
225
234
  else
226
235
  'unknown'
227
236
  end
228
- browser = ENV['WEB_BROWSER'].downcase.to_sym
237
+ browser = Environ.browser.downcase.to_sym
229
238
 
230
239
  case browser
231
240
  when :firefox, :chrome, :ie, :safari, :edge
@@ -235,7 +244,7 @@ module TestCentricity
235
244
  Environ.headless = true
236
245
  else
237
246
  Environ.platform = :mobile
238
- Environ.device_name = Browsers.mobile_device_name(ENV['WEB_BROWSER'])
247
+ Environ.device_name = Browsers.mobile_device_name(Environ.browser)
239
248
  end
240
249
 
241
250
  Capybara.register_driver :selenium do |app|
@@ -253,8 +262,8 @@ module TestCentricity
253
262
  Capybara::Selenium::Driver.new(app, browser: :edge, capabilities: [options])
254
263
  else
255
264
  if ENV['HOST_BROWSER'] && ENV['HOST_BROWSER'].downcase.to_sym == :chrome
256
- user_agent = Browsers.mobile_device_agent(ENV['WEB_BROWSER'])
257
- options = Selenium::WebDriver::Chrome::Options.new(options: {'excludeSwitches' => ['enable-automation']})
265
+ user_agent = Browsers.mobile_device_agent(Environ.browser)
266
+ options = Selenium::WebDriver::Chrome::Options.new
258
267
  options.add_argument('--disable-dev-shm-usage')
259
268
  options.add_argument("--user-agent='#{user_agent}'")
260
269
  options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
@@ -269,7 +278,7 @@ module TestCentricity
269
278
 
270
279
  def self.initialize_remote
271
280
  Environ.grid = :selenium_grid
272
- browser = ENV['WEB_BROWSER'].downcase.to_sym
281
+ browser = Environ.browser.downcase.to_sym
273
282
  @endpoint = ENV['REMOTE_ENDPOINT'] || 'http://127.0.0.1:4444/wd/hub' if @endpoint.nil?
274
283
 
275
284
  case browser
@@ -284,9 +293,9 @@ module TestCentricity
284
293
  else
285
294
  if ENV['HOST_BROWSER'] && ENV['HOST_BROWSER'].downcase.to_sym == :chrome
286
295
  Environ.platform = :mobile
287
- Environ.device_name = Browsers.mobile_device_name(ENV['WEB_BROWSER'])
288
- user_agent = Browsers.mobile_device_agent(ENV['WEB_BROWSER'])
289
- options = Selenium::WebDriver::Chrome::Options.new(options: {'excludeSwitches' => ['enable-automation']})
296
+ Environ.device_name = Browsers.mobile_device_name(Environ.browser)
297
+ user_agent = Browsers.mobile_device_agent(Environ.browser)
298
+ options = Selenium::WebDriver::Chrome::Options.new
290
299
  options.add_argument('--disable-dev-shm-usage')
291
300
  options.add_argument("--user-agent='#{user_agent}'")
292
301
  options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
@@ -390,7 +399,7 @@ module TestCentricity
390
399
  else
391
400
  # define desktop browser options
392
401
  bs_options[:resolution] = ENV['RESOLUTION'] if ENV['RESOLUTION']
393
- bs_options[:seleniumVersion] = '4.1.0'
402
+ bs_options[:seleniumVersion] = '4.3.0'
394
403
  {
395
404
  browserName: browser,
396
405
  browserVersion: ENV['BS_VERSION'],
@@ -488,7 +497,7 @@ module TestCentricity
488
497
  # define mobile device options
489
498
  if ENV['SL_PLATFORM']
490
499
  sl_options[:deviceOrientation] = ENV['ORIENTATION'].upcase if ENV['ORIENTATION']
491
- sl_options[:appiumVersion] = '1.22.0'
500
+ sl_options[:appiumVersion] = '1.22.3'
492
501
  {
493
502
  browserName: browser,
494
503
  platformName: ENV['SL_PLATFORM'],
@@ -572,9 +581,9 @@ module TestCentricity
572
581
  def self.chrome_edge_options(browser)
573
582
  options = case browser
574
583
  when :chrome, :chrome_headless
575
- Selenium::WebDriver::Chrome::Options.new(options: {'excludeSwitches' => ['enable-automation']})
584
+ Selenium::WebDriver::Chrome::Options.new
576
585
  when :edge, :edge_headless
577
- Selenium::WebDriver::Edge::Options.new(options: {'excludeSwitches' => ['enable-automation']})
586
+ Selenium::WebDriver::Edge::Options.new
578
587
  end
579
588
  prefs = {
580
589
  prompt_for_download: false,
@@ -213,6 +213,114 @@ module TestCentricity
213
213
  obj.native.attribute('volume').to_f
214
214
  end
215
215
 
216
+ # Return number of text tracks of associated media
217
+ #
218
+ # @return [Integer] number of text tracks
219
+ # @example
220
+ # num_tracks = media_player.track_count
221
+ #
222
+ def track_count
223
+ obj, = find_element(visible = :all)
224
+ object_not_found_exception(obj, @type)
225
+ page.execute_script('return arguments[0].textTracks.length', obj)
226
+ end
227
+
228
+ # Return index of active text track of associated media
229
+ #
230
+ # @return [Integer] number of active text track
231
+ # @example
232
+ # track_num = media_player.active_track
233
+ #
234
+ def active_track
235
+ num_tracks = track_count
236
+ return 0 if num_tracks.zero?
237
+
238
+ obj, = find_element(visible = :all)
239
+ object_not_found_exception(obj, @type)
240
+ (0..num_tracks).each do |track|
241
+ track_info = page.execute_script("return arguments[0].textTracks[#{track}].mode", obj)
242
+ return track + 1 if track_info == 'showing'
243
+ end
244
+ 0
245
+ end
246
+
247
+ # Return properties of active text track of associated media
248
+ #
249
+ # @return [Hash] properties of active text track (:kind, :label, :language, :mode)
250
+ # @example
251
+ # track_info = media_player.active_track_data
252
+ #
253
+ def active_track_data
254
+ active = active_track
255
+ return nil if active.zero?
256
+
257
+ track_data(active)
258
+ end
259
+
260
+ # Return properties of all text tracks of associated media
261
+ #
262
+ # @return [Array of Hash] properties of active text track (:kind, :label, :language, :mode)
263
+ # @example
264
+ # all_track_info = media_player.all_tracks_data
265
+ #
266
+ def all_tracks_data
267
+ num_tracks = track_count
268
+ return 0 if num_tracks.zero?
269
+
270
+ all_data = []
271
+ (1..num_tracks).each do |track|
272
+ all_data.push( { track => track_data(track) })
273
+ end
274
+ all_data
275
+ end
276
+
277
+ # Return properties of specified text track of associated media
278
+ #
279
+ # @param track [Integer] index of requested track
280
+ # @return [Hash] properties of requested text track (:kind, :label, :language, :mode)
281
+ # @example
282
+ # track_info = media_player.track_data(1)
283
+ #
284
+ def track_data(track)
285
+ obj, = find_element(visible = :all)
286
+ object_not_found_exception(obj, @type)
287
+ track_mode = page.execute_script("return arguments[0].textTracks[#{track - 1}].mode", obj)
288
+ track_obj = obj.find(:css, "track:nth-of-type(#{track})", visible: :all, wait: 1)
289
+ {
290
+ kind: track_obj[:kind],
291
+ label: track_obj[:label],
292
+ language: track_obj[:srclang],
293
+ mode: track_mode
294
+ }
295
+ end
296
+
297
+ # Return src property of active text track of associated media
298
+ #
299
+ # @return [String] src property of active text track
300
+ # @example
301
+ # track_src = media_player.active_track_source
302
+ #
303
+ def active_track_source
304
+ active = active_track
305
+ return nil if active.zero?
306
+
307
+ track_source(active)
308
+ end
309
+
310
+ # Return srv property of specified text track of associated media
311
+ #
312
+ # @param track [Integer] index of requested track
313
+ # @return [String] src property of requested text track
314
+ # @example
315
+ # track_src = media_player.track_source(2)
316
+ #
317
+ def track_source(track)
318
+ obj, = find_element(visible = :all)
319
+ object_not_found_exception(obj, @type)
320
+ track_obj = obj.find(:css, "track:nth-of-type(#{track})", visible: :all, wait: 1)
321
+ track_obj[:src]
322
+ end
323
+
216
324
  # Set the media currentTime property
217
325
  #
218
326
  # @param value [Float] time in seconds
@@ -42,6 +42,34 @@ module TestCentricity
42
42
  obj.native.attribute('placeholder')
43
43
  end
44
44
 
45
+ # Return validationMessage property of a textfield, which is the message the browser displays to the user when a textfield's
46
+ # validity is checked and fails. Note that each web browser provides a default localized message for this property, and message
47
+ # strings can vary between different browsers (Chrome/Edge vs Firefox vs Safari).
48
+ #
49
+ # @return [String]
50
+ # @example
51
+ # message = username_field.validation_message
52
+ #
53
+ def validation_message
54
+ obj, = find_element
55
+ object_not_found_exception(obj, nil)
56
+ obj.native.attribute('validationMessage')
57
+ end
58
+
59
+ # Return Boolean value representing
60
+ #
61
+ # @param validity_state [Symbol] property to verify
62
+ # @return [Boolean]
63
+ # @example
64
+ # username_field.validity?(:valid)
65
+ # username_field.validity?(:valueMissing)
66
+ #
67
+ def validity?(validity_state)
68
+ obj, = find_element
69
+ object_not_found_exception(obj, nil)
70
+ page.execute_script("return arguments[0].validity.#{validity_state}", obj)
71
+ end
72
+
45
73
  # Return min attribute of a number type text field.
46
74
  #
47
75
  # @return [Integer]
@@ -47,7 +47,7 @@ module TestCentricity
47
47
  attr_accessor :base_object
48
48
 
49
49
  XPATH_SELECTORS = ['//', '[@', '[contains(']
50
- CSS_SELECTORS = ['#', ':nth-child(', ':first-child', ':last-child', ':nth-of-type(', ':first-of-type', ':last-of-type', '^=', '$=', '*=', ':contains(']
50
+ CSS_SELECTORS = %w[# :nth-child( :first-child :last-child :nth-of-type( :first-of-type :last-of-type ^= $= *= :contains(]
51
51
 
52
52
  def initialize(name, parent, locator, context)
53
53
  @name = name
@@ -390,6 +390,44 @@ module TestCentricity
390
390
  end
391
391
  end
392
392
 
393
+ # Wait until the object is enabled, or until the specified wait time has expired. If the wait time is nil, then the
394
+ # wait time will be Capybara.default_max_wait_time.
395
+ #
396
+ # @param seconds [Integer or Float] wait time in seconds
397
+ # @example
398
+ # run_button.wait_until_enabled(10)
399
+ #
400
+ def wait_until_enabled(seconds = nil, post_exception = true)
401
+ timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
402
+ wait = Selenium::WebDriver::Wait.new(timeout: timeout)
403
+ wait.until { enabled? }
404
+ rescue StandardError
405
+ if post_exception
406
+ raise "UI #{object_ref_message} remained disabled after #{timeout} seconds" unless enabled?
407
+ else
408
+ enabled?
409
+ end
410
+ end
411
+
412
+ # Wait until the object is no longer in a busy state, or until the specified wait time has expired. If the wait time
413
+ # is nil, then the wait time will be Capybara.default_max_wait_time.
414
+ #
415
+ # @param seconds [Integer or Float] wait time in seconds
416
+ # @example
417
+ # login_button.wait_while_busy(10)
418
+ #
419
+ def wait_while_busy(seconds = nil, post_exception = true)
420
+ timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
421
+ wait = Selenium::WebDriver::Wait.new(timeout: timeout)
422
+ wait.until { aria_busy? }
423
+ rescue StandardError
424
+ if post_exception
425
+ raise "UI #{object_ref_message} remained in busy state after #{timeout} seconds" if aria_busy?
426
+ else
427
+ aria_busy?
428
+ end
429
+ end
430
+
393
431
  # Wait until the object's value equals the specified value, or until the specified wait time has expired. If the wait
394
432
  # time is nil, then the wait time will be Capybara.default_max_wait_time.
395
433
  #