Module: Continuum

Defined in:
src/lib/continuum.rb,
src/lib/continuum/error.rb,
src/lib/continuum/proxy.rb,
src/lib/continuum/logger.rb,
src/lib/continuum/module.rb,
src/lib/continuum/report.rb,
src/lib/continuum/fix_type.rb,
src/lib/continuum/metadata.rb,
src/lib/continuum/standard.rb,
src/lib/continuum/assertion.rb,
src/lib/continuum/data_util.rb,
src/lib/continuum/test_type.rb,
src/lib/continuum/test_result.rb,
src/lib/continuum/network_util.rb,
src/lib/continuum/configuration.rb,
src/lib/continuum/clustering_data.rb,
src/lib/continuum/best_practice_data.rb,
src/lib/continuum/accessibility_concern.rb,
src/lib/continuum/amp_reporting_service.rb,
src/lib/continuum/level_access_platform.rb,
src/lib/continuum/module_management_strategy.rb,
src/lib/continuum/report_management_strategy.rb,
src/lib/continuum/level_access_platform_reporting_service.rb

Overview

This module encapsulates all of the helper functionality Access Continuum offers for running Access Engine to test web projects.

Defined Under Namespace

Modules: DataUtil, NetworkUtil Classes: AMPReportingService, AccessibilityConcern, Assertion, BestPracticeData, ClusteringData, Configuration, Error, FixType, HttpErrorException, LevelAccessPlatform, LevelAccessPlatformReportingService, Metadata, Module, ModuleManagementStrategy, NotFoundException, Proxy, Report, ReportManagementStrategy, Standard, TestResult, TestType

Class Method Summary collapse

Class Method Details

.accessibility_concernsArray<AccessibilityConcern>

Gets the list of accessibility concerns found by Access Engine during the last test execution.

Returns:

  • (Array<AccessibilityConcern>)

    The list of accessibility concerns found by Access Engine during the last test execution



42
43
44
# File 'src/lib/continuum.rb', line 42

def self.accessibility_concerns
  @accessibility_concerns
end

.amp_reporting_serviceAMPReportingService

Gets the instance of the AMP reporting service associated with this instance of Continuum. Please consult our support documentation for more information on how to report to AMP.

Returns:

  • (AMPReportingService)

    The AMP reporting service associated with this instance of Continuum



90
91
92
# File 'src/lib/continuum.rb', line 90

def self.amp_reporting_service
  @amp_reporting_service
end

.assertionsObject



46
47
48
# File 'src/lib/continuum.rb', line 46

def self.assertions
  @assertions
end

.configurationConfiguration

Gets the instance of the Configuration that was created during set_up. Please consult Configuration documentation for more information on what configurations are available.

Returns:

  • (Configuration)

    The Configuration instance associated with this instance of Continuum



109
110
111
# File 'src/lib/continuum.rb', line 109

def self.configuration
  @configuration
end

.get_access_engine_versionString

Retrieves the version of Access Engine being used.

Returns:

  • (String)

    The version of Access Engine being used.



247
248
249
250
251
# File 'src/lib/continuum.rb', line 247

def self.get_access_engine_version
  inject_access_engine()

  @web_driver.execute_script('return LevelAccess_Continuum_AccessEngine.getVersion();')
end

.get_page_metadataMetadata

Retrieves the set of metadata for the current page.

Returns:

  • (Metadata)

    The set of metadata for the current page.



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'src/lib/continuum.rb', line 223

def self.
  inject_access_engine()

  content_type = @web_driver.execute_script('return document.contentType;')
  environment_details = @web_driver.execute_script('return LevelAccess_Continuum_AccessEngine.getEnvironmentDetails();')
  engine_success = @web_driver.execute_script('return LevelAccess_Continuum_AccessEngine.getSuccess();')

  Metadata.new(
    content_type: content_type,
    title: @web_driver.title,
    redirected_url: @web_driver.current_url,
    width: environment_details['width'].to_i,
    height: environment_details['height'].to_i,
    doc_width: environment_details['docWidth'].to_i,
    doc_height: environment_details['docHeight'].to_i,
    orientation: environment_details['orientation'],
    user_agent: environment_details['userAgent'],
    engine_success: engine_success || false
  )
end

.get_supported_best_practicesHash

Gets a map of IDs of best practices (defined in AMP and supported by Continuum) to their descriptions for the current test context and mobile type used previously to invoke set_up. Make sure to invoke the set_up method before invoking this method.

If a connection to AMP could not be established when best practice data was fetched from AMP, i.e. when Continuum was instantiated, this will return an empty map.

Returns:

  • (Hash)

    A map of IDs of best practices to their descriptions



133
134
135
# File 'src/lib/continuum.rb', line 133

def self.get_supported_best_practices
  @web_best_practice_name_by_id
end

.get_supported_standardsHash

Gets a map of IDs of accessibility standards (defined in AMP and supported by Continuum) to their names for the current test context and mobile type used previously to invoke set_up. Make sure to invoke the set_up method before invoking this method.

If a connection to AMP could not be established when best practice data was fetched from AMP, i.e. when Continuum was instantiated, this will return an empty map.

Returns:

  • (Hash)

    A map of IDs of accessibility standards to their names



121
122
123
# File 'src/lib/continuum.rb', line 121

def self.get_supported_standards
  @web_standard_name_by_id
end

.get_supported_testsHash

Gets a map of IDs of automatic Access Engine tests (supported by Continuum) to their descriptions for the current test context and mobile type used previously to invoke set_up. Make sure to invoke the set_up method before invoking this method.

Returns:

  • (Hash)

    A map of IDs of Access Engine tests to their descriptions



142
143
144
# File 'src/lib/continuum.rb', line 142

def self.get_supported_tests
  @web_test_name_by_id
end

.include_potential_accessibility_concernsBoolean

Gets whether or not accessibility concerns that require manual review are included in any of Continuum’s test results. If enabled, any accessibility concerns that require manual review will have Continuum::AccessibilityConcern#needs_review return true. By default, this is specified by Continuum::Configuration#include_potential_accessibility_concerns, i.e. the value for the ‘includePotentialAccessibilityConcerns’ attribute defined in continuum.json. This setting can be toggled programmatically by setting include_potential_accessibility_concerns, overriding the value specified in continuum.json.

Returns:

  • (Boolean)

    ‘true` if accessibility concerns that require manual review are included in any of Continuum’s test results, false if they are not.



59
60
61
# File 'src/lib/continuum.rb', line 59

def self.include_potential_accessibility_concerns
  @include_potential_accessibility_concerns
end

.include_potential_accessibility_concerns=(value) ⇒ Object

Note:

This method is only available in the Pro edition of Continuum.

Globally sets whether or not accessibility concerns that require manual review are included in any of Continuum’s test results. If enabled, any accessibility concerns that require manual review will have Continuum::AccessibilityConcern#needs_review return true. Using this method will override the value for the ‘includePotentialAccessibilityConcerns’ attribute defined in continuum.json, which is otherwise used by default.

Parameters:

  • value (Boolean)

    ‘true` if accessibility concerns that require manual review should be included in any of Continuum’s test results, false if not.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'src/lib/continuum.rb', line 70

def self.include_potential_accessibility_concerns=(value)
  if value && !@configuration.is_pro_edition?
    logger.info(%{
      `include_potential_accessibility_concerns=` is not available in the Community
      edition of Continuum. Please upgrade to the Pro edition of Continuum for access
      to this method.
    })
    value = false
  end

  @include_potential_accessibility_concerns = value

  # Continuum needs to be reinitialized to properly propagate the changes above
  set_up(@web_driver, @config_path)
end

.level_access_platform_reporting_serviceLevelAccessPlatformReportingService

Gets the instance of the Level Access Platform reporting service associated with this instance of Continuum. Please consult our support documentation for more information on how to report to Level Access Platform.

Returns:



101
102
103
# File 'src/lib/continuum.rb', line 101

def self.level_access_platform_reporting_service
  @level_access_platform_reporting_service
end

.loggerLogger

Returns An instance of Logger for printing log messages.

Returns:

  • (Logger)

    An instance of Logger for printing log messages.



8
9
10
# File 'src/lib/continuum/logger.rb', line 8

def self.logger
  @logger ||= Logger.new(STDOUT, level: Logger::INFO, progname: 'continuum-ruby')
end

.run_all_tests(selector_for_node_to_test = nil) ⇒ Array<AccessibilityConcern>

Tests the page currently under test for accessibility concerns using Access Engine, injecting Access Engine into the page if it is not already present.

Parameters:

  • selector_for_node_to_test (String, nil) (defaults to: nil)

    A CSS selector to restrict accessibility testing to

Returns:



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'src/lib/continuum.rb', line 278

def self.run_all_tests(selector_for_node_to_test = nil)
  test_type_json_array_string = @include_potential_accessibility_concerns ? '[4,5]' : '[4]'

  inject_access_engine()

  if selector_for_node_to_test
    if @include_potential_accessibility_concerns
      script = %{
        return LevelAccess_Continuum_AccessEngine.ast_runAllTests_returnInstances_JSON_NodeCapture(
          document.querySelector("#{selector_for_node_to_test}"),#{test_type_json_array_string}
        );
      }
    else
      script = %{
        return LevelAccess_Continuum_AccessEngine.runAllTests_returnInstances_JSON_NodeCapture(
          document.querySelector("#{selector_for_node_to_test}")
        );
      }
    end
  else
    script = %{
      return LevelAccess_Continuum_AccessEngine.ast_runAllTests_returnInstances_JSON(#{test_type_json_array_string});
    }
  end

  concerns = convert_access_engine_results_to_accessibility_concerns(@web_driver.execute_script(script))
  concerns = filter_and_enrich_accessibility_concerns(concerns)
  @accessibility_concerns = concerns

  return concerns
end

.run_all_tests_for_assertionsArray<Assertion>

Runs the Access Engine tests against the current page returning the results in the assertions format.

Returns:

  • (Array<Assertion>)

    The list of assertions tested by Access Engine for the current page of the web driver



420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'src/lib/continuum.rb', line 420

def self.run_all_tests_for_assertions
  test_type_json_array_string = @include_potential_accessibility_concerns ? '[4,5]' : '[4]'

  results = @web_driver.execute_script("return LevelAccess_Continuum_AccessEngine.nextgen_runAllTests_returnInstances_JSON(#{test_type_json_array_string});")

  results_array = DataUtil.parse_json(results)
  results_array.map do |assertion_data|
    Assertion.from_json(assertion_data)
  end

  @assertions = results_array
  return @assertions
end

.run_tests(access_engine_test_ids, selector_for_node_to_test = nil) ⇒ Array<AccessibilityConcern>

Runs only the specified Access Engine tests against the current page for only the specified node and all its children.

Parameters:

  • access_engine_test_ids (Array<String>)

    The IDs of the automatic Access Engine tests to test for (invoke get_supported_tests for a list of these, or consult AMP)

  • selector_for_node_to_test (String, nil) (defaults to: nil)

    A CSS selector to restrict accessibility testing to

Returns:

  • (Array<AccessibilityConcern>)

    The list of accessibility concerns found by Access Engine for the current page of the web driver that match the specified tests



261
262
263
264
265
266
267
268
269
270
271
# File 'src/lib/continuum.rb', line 261

def self.run_tests(access_engine_test_ids, selector_for_node_to_test = nil)
  # Technically, we actually run all tests and then filter them afterwards
  concerns = run_all_tests(selector_for_node_to_test)

  filtered_concerns = concerns.select do |concern|
    access_engine_test_ids.include?(concern.engine_test_id)
  end

  @accessibility_concerns = filtered_concerns
  return filtered_concerns
end

.set_up(web_driver, config_path) ⇒ Object

Sets up Continuum for web testing.

Parameters:

  • web_driver (Selenium::WebDriver::Driver)

    A Selenium web driver to test with

  • config_path (String)

    The absolute path to a valid continuum.json file



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'src/lib/continuum.rb', line 150

def self.set_up(web_driver, config_path)
  @web_driver = web_driver
  @config_path = config_path
  @configuration = Configuration.new(@config_path)

  if include_potential_accessibility_concerns.nil?
    self.include_potential_accessibility_concerns = @configuration.include_potential_accessibility_concerns
    return # The setter for `include_potential_accessibility_concerns` calls `set_up` again and will complete setup
  end

  # Inject Engine and fetch info about its automatic tests
  inject_access_engine()

  if @amp_reporting_service
    @amp_reporting_service.driver = @web_driver
  else
    @amp_reporting_service = AMPReportingService.new(@web_driver)
  end

  access_engine_version = get_access_engine_version.delete_suffix('-SNAPSHOT').gsub(/-\w+\.\d+/, '')
  if @level_access_platform_reporting_service
    @level_access_platform_reporting_service.driver = @web_driver
    @level_access_platform_reporting_service.access_engine_version = access_engine_version
  else
    @level_access_platform_reporting_service = LevelAccessPlatformReportingService.new(@web_driver, access_engine_version)
  end

  # Parse and bucket test info by platform
  begin
    test_info = get_test_info()
    if test_info
      test_info.each do |test_info_id, test_info_data|
        test_id = test_info_id.to_i
        media_type = test_info_data['mediaType'].to_i

        if media_type == 1
          best_practice_id = test_info_data['bestPractice'].to_i
          @web_best_practice_ids.push(best_practice_id)
          @web_test_name_by_id[test_id] = test_info_data['description']
        end
      end
    end
  rescue => e
    logger.error(e)
  ensure
    unless test_info
      logger.warn(%{
        Failed to fetch info about tests supported by Access Engine!
        Continuum is now operating in a degraded state; get_supported_tests(),
        get_supported_best_practices(), and get_supported_standards() will not return
        any data.
      })
    end
  end

  # Prefetch best practice data from AMP
  begin
    fetch_best_practice_data()
  rescue => e
    logger.error(e)
    logger.warn(%{
      Failed to fetch enriched best practice data from AMP!
      Continuum is now operating in a degraded state;
      both get_supported_best_practices() and get_supported_standards()
      will not return any data, and accessibility concerns returned by Continuum
      will not be enriched with corresponding best practice data from AMP.
    })
  end
end

.test_for_best_practices(best_practice_ids, selector_for_node_to_test = nil) ⇒ Array<AccessibilityConcern>

Runs only the automatic Access Engine tests corresponding to the specified best practices against the current page, for only the specified node and all its children.

Parameters:

  • best_practice_ids (Array<String>)

    The IDs of the best practices to test for (invoke get_supported_best_practices for a list of these, or consult AMP)

  • selector_for_node_to_test (String, nil) (defaults to: nil)

    A CSS selector to restrict accessibility testing to

Returns:

  • (Array<AccessibilityConcern>)

    The list of accessibility concerns found by Access Engine for the current page of the web driver that match the specified best practices



344
345
346
347
348
349
350
351
352
353
354
# File 'src/lib/continuum.rb', line 344

def self.test_for_best_practices(best_practice_ids, selector_for_node_to_test = nil)
  # Technically, we actually run all tests and then filter them afterwards
  concerns = run_all_tests(selector_for_node_to_test)

  filtered_concerns = concerns.select do |concern|
    best_practice_ids.include?(concern.best_practice_id)
  end

  @accessibility_concerns = filtered_concerns
  return filtered_concerns
end

.test_for_noticeability(min_noticeability, selector_for_node_to_test = nil) ⇒ Array<AccessibilityConcern>

Runs only the automatic Access Engine tests of or greater than the specified noticeability against the current page, for only the specified node and all its children.

Parameters:

  • min_noticeability (Integer)

    The inclusive minimum noticeability of accessibility concerns to test. On a scale of 1 to 10, 1 is the least noticeable and 10 is the most noticeable.

  • selector_for_node_to_test (String, nil) (defaults to: nil)

    A CSS selector to restrict accessibility testing to

Returns:

  • (Array<AccessibilityConcern>)

    The list of accessibility concerns found by Access Engine for the current page of the web driver whose noticeability is equal to or greater than ‘min_noticeability`



404
405
406
407
408
409
410
411
412
413
414
# File 'src/lib/continuum.rb', line 404

def self.test_for_noticeability(min_noticeability, selector_for_node_to_test = nil)
  # Technically, we actually run all tests and then filter them afterwards
  concerns = run_all_tests(selector_for_node_to_test)

  filtered_concerns = concerns.select do |concern|
    concern.noticeability && concern.noticeability >= min_noticeability
  end

  @accessibility_concerns = filtered_concerns
  return filtered_concerns
end

.test_for_severity(min_severity, selector_for_node_to_test = nil) ⇒ Array<AccessibilityConcern>

Runs only the automatic Access Engine tests of or greater than the specified severity against the current page, for only the specified node and all its children.

Parameters:

  • min_severity (Integer)

    The inclusive minimum severity of accessibility concerns to test. On a scale of 1 to 10, 1 is the least severe and 10 is the most severe.

  • selector_for_node_to_test (String, nil) (defaults to: nil)

    A CSS selector to restrict accessibility testing to

Returns:

  • (Array<AccessibilityConcern>)

    The list of accessibility concerns found by Access Engine for the current page of the web driver whose severity is equal to or greater than ‘min_severity`



364
365
366
367
368
369
370
371
372
373
374
# File 'src/lib/continuum.rb', line 364

def self.test_for_severity(min_severity, selector_for_node_to_test = nil)
  # Technically, we actually run all tests and then filter them afterwards
  concerns = run_all_tests(selector_for_node_to_test)

  filtered_concerns = concerns.select do |concern|
    concern.severity && concern.severity >= min_severity
  end

  @accessibility_concerns = filtered_concerns
  return filtered_concerns
end

.test_for_standards(standard_ids, selector_for_node_to_test = nil) ⇒ Array<AccessibilityConcern>

Runs only the automatic Access Engine tests corresponding to the specified accessibility standards against the current page, for only the specified node and all its children. Note that the IDs of the specified accessibility standards must also be specified by Continuum::Configuration#default_standard_ids, i.e. in the set of IDs implied from the value of the ‘defaultStandardIds’ attribute defined in continuum.json, otherwise no accessibility concerns will be returned.

Parameters:

  • standard_ids (Array<Integer>)

    The IDs of the accessibility standards to test for (invoke get_supported_standards for a list of these, or consult AMP)

  • selector_for_node_to_test (String, nil) (defaults to: nil)

    A CSS selector to restrict accessibility testing to

Returns:

  • (Array<AccessibilityConcern>)

    The list of accessibility concerns found by Access Engine for the current page of the web driver that match the specified accessibility standards



321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'src/lib/continuum.rb', line 321

def self.test_for_standards(standard_ids, selector_for_node_to_test = nil)
  # Technically, we actually run all tests and then filter them afterwards
  concerns = run_all_tests(selector_for_node_to_test)

  filtered_concerns = concerns.select do |concern|
    if concern.best_practice_standards && concern.best_practice_standards.size > 0
      accessibility_concern_standard_ids = concern.best_practice_standards.map { |standard| standard.id }
      accessibility_concern_standard_ids & standard_ids # intersection
    end
  end

  @accessibility_concerns = filtered_concerns
  return filtered_concerns
end

.test_for_tractability(min_tractability, selector_for_node_to_test = nil) ⇒ Array<AccessibilityConcern>

Runs only the automatic Access Engine tests of or greater than the specified tractability against the current page, for only the specified node and all its children.

Parameters:

  • min_tractability (Integer)

    The inclusive minimum tractability of accessibility concerns to test. On a scale of 1 to 10, 1 is the least tractable and 10 is the most tractable.

  • selector_for_node_to_test (String, nil) (defaults to: nil)

    A CSS selector to restrict accessibility testing to

Returns:

  • (Array<AccessibilityConcern>)

    The list of accessibility concerns found by Access Engine for the current page of the web driver whose tractability is equal to or greater than ‘min_tractability`



384
385
386
387
388
389
390
391
392
393
394
# File 'src/lib/continuum.rb', line 384

def self.test_for_tractability(min_tractability, selector_for_node_to_test = nil)
  # Technically, we actually run all tests and then filter them afterwards
  concerns = run_all_tests(selector_for_node_to_test)

  filtered_concerns = concerns.select do |concern|
    concern.tractability && concern.tractability >= min_tractability
  end

  @accessibility_concerns = filtered_concerns
  return filtered_concerns
end