The class Continuum {
encapsulates all of the helper functionality Level Access testing SDKs offer for running Access Engine to test web projects.
Members
LevelAccessPlatformReportingService
Purpose
Gets the instance of the Level Access Platform reporting service associated with this instance of Level Access testing SDKs. Please consult our support documentation for more information on how to report to the Level Access Platform.
Example
get LevelAccessPlatformReportingService() { return this._LevelAccessPlatformReportingService; } set LevelAccessPlatformReportingService(LevelAccessPlatformReportingService) { this._LevelAccessPlatformReportingService = LevelAccessPlatformReportingService; }
Methods
createInjectableAccessEngineCode(accessEngineCode) → {string}
Purpose
Creates injectable Access Engine code from the specified Access Engine code to allow you to inject it into a page and used. Use this method to inject Access Engine into the page yourself rather than the SDK injecting.
Example
createInjectableAccessEngineCode(accessEngineCode) {
accessEngineCode += "window.LevelAccess_Continuum_AccessEngine = LevelAccess_AccessEngine;";
return accessEngineCode;
}
getAssertions() → {array. <Assertion>}
Purpose
Gets the array of assertions tested by Access Engine during the last test execution.
Example
getAssertions() { return this.assertions; }
(async) getPageMetadata → {metadata}
Purpose
Gets the metadata for the current page.
Example
async getPageMetadata() { // TODO: determine if can be reused by EAP-15704 this._injectAccessEngine();
const metadata = new Metadata(); let environmentDetails = {};
if (this._useBrowser()) { metadata.contentType = await this._executeScript("return document.contentType"); metadata.title = await this._getTitle(); metadata.redirectedUrl = await this._getCurrentUrl(); environmentDetails = await this._executeScript("return window.LevelAccess_Continuum_AccessEngine.getEnvironmentDetails();"); metadata.engineSuccess = await this._executeScript("return window.LevelAccess_Continuum_AccessEngine.getSuccess();"); } else if (this.windowUnderTest) { const { document } = this.windowUnderTest; metadata.contentType = document.contentType; metadata.title = document.title; metadata.redirectedUrl = document.location.href; environmentDetails = this.windowUnderTest.LevelAccess_Continuum_AccessEngine.getEnvironmentDetails(); metadata.engineSuccess = this.windowUnderTest.LevelAccess_Continuum_AccessEngine.getSuccess(); }
metadata.width = environmentDetails.width; metadata.height = environmentDetails.height; metadata.docHeight = environmentDetails.docHeight; metadata.docWidth = environmentDetails.docWidth; metadata.orientation = environmentDetails.orientation; metadata.userAgent = environmentDetails.userAgent;
return metadata; }
getSupportedTests () → {object}
Purpose
Gets an object of key-value pairs, where the keys are IDs of automatic Access Engine tests (supported by Level Access testing SDKs) and the values are their description. Make sure to invoke the Continuum#setUp method before invoking this method.
Example
getSupportedTests() {
return this.webTestNameById;
}
(async) setUp(webDrivernullable, configPathOrObjectnullable, windownullable, browsernullable)
Purpose
Sets up Continuum for web testing. Either the webDriver or window parameter must be specified here.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
webDriver | * | <nullable> | A Selenium web driver to test with. |
configurPathOrObject | string | object | <nullable> | Either the absolute path to a valid continuum.conf.js file or an object containing the configuration properties. Null if you've already loaded this yourself and have supplied a window object. |
window | Window | <nullable> | The window whose content should be tested. |
browser | * | <nullable> | A WebDriverIO browser to test with. |
Example
async setUp(webDriver, configPathOrObject, window, browser) { this.driver = webDriver; this.configPath = (typeof configPathOrObject === 'string') ? configPathOrObject : null; this.configObject = (typeof configPathOrObject === 'object') ? configPathOrObject : null; this.windowUnderTest = window; this.browser = browser Configuration.load(configPathOrObject); if (this._includePotentialAccessibilityConcerns === null) { if (await this.setIncludePotentialAccessibilityConcerns(Configuration.getIncludePotentialAccessibilityConcerns())) { // on success, setIncludePotentialAccessibilityConcerns calls setUp, so no need to finish executing setUp here return; } } this._retrieveAccessEngineCode(); let testDataFetched = false; try { // inject Engine and fetch info about its automatic tests const testInfo = await this._getTestInfo(); // parse and bucket test info by platform if (testInfo != null) { Object.keys(testInfo).forEach((testIdString) = { const testId = parseInt(testIdString, 10); const testInfoData = testInfo[testId]; if (testInfoData.mediaType === 1) { const bestPracticeId = parseInt(testInfoData.bestPractice, 10); this.webBestPracticeIds.push(bestPracticeId); this.webTestNameById[testId] = testInfoData.description; } }); testDataFetched = true; } } catch (err) { console.log(err); } finally { if (!testDataFetched) { console.log("Failed to fetch info about tests supported by Access Engine! Continuum is now operating in a degraded state; getSupportedTests(), getSupportedBestPractices(), and getSupportedStandards() will not return any data."); } } try { // prefetch best practice data from AMP await this._fetchBestPracticeData(); } catch (err) { console.log("Failed to fetch enriched best practice data from AMP! Continuum is now operating in a degraded state; both getSupportedBestPractices() and getSupportedStandards() will not return any data, and accessibility concerns returned by Continuum will not be enriched with corresponding best practice data from AMP.", err); } let accessEngineVersion; try { accessEngineVersion = await this._getAccessEngineVersion(); } catch (err) { console.log("Failed to retrieve Access Engine version.", err); } if (this._AMPReportingService === null) { this._AMPReportingService = new AMPReportingService(this._driver, this._windowUnderTest, this._browser); } if (this._LevelAccessPlatformReportingService === null) { this._LevelAccessPlatformReportingService = new LevelAccessPlatformReportingService(this._driver, this._windowUnderTest, this._browser, accessEngineVersion); } }
setWindowUnderTest(targetWindow) → {Promise}
Purpose
Sets the window to test. This can be used to set the testing context to the contents of an iframe element on the page, rather than the page an iframe element appears on.
Parameters
Name | Type | Description |
---|---|---|
targetWindow | Window | The window to inject Access Engine into and prepare to test. |
Example
setWindowUnderTest(targetWindow) { return new Promise((resolve, reject) = { const injectAccessEngine = this._injectAccessEngine(); const execApi = new Promise((resolve, reject) = { if (this._useBrowser()) { // not supported reject(); } else if (this.windowUnderTest) { this.windowUnderTest.LevelAccess_Continuum_AccessEngine.setWindowUnderTest(targetWindow); resolve(); } else { reject(); } }); const arr = [injectAccessEngine, execApi]; Promise.all(arr).then(() = { resolve(); }); }); } _convertAccessEngineResultsToAssertions(results, baseUel = null, baseCss = null) { if (!results) { return null; } const resultsArr = JSON.parse(results); let assertions = []; resultsArr.forEach(result = { const assertion = { ...Assertion.fromJSON(result) }; if (baseUel && baseCss) { assertion.results.forEach((result) = { result.uel = `${baseUel}${result.uel}`; result.css = `${baseCss}||${result.css}`; }); } assertions.push(assertion); }); return assertions; } _combineAssertions(assertions, extraAssertions) { if (!assertions || !extraAssertions) { return assertions; } if (assertions.length <= 0)="0)" {="{" return="return" extraassertions;="extraAssertions;" }="}" assertions.foreach((assertion)="assertions.forEach((assertion)"> { const extraAssertion = extraAssertions.find((extra) = { return assertion.testId === extra.testId; }); if (extraAssertion && extraAssertion.results.length 0) { assertion.outcome = extraAssertion.outcome; assertion.results = assertion.results.concat(extraAssertion.results); } }); return assertions; }</=>
Comments
0 comments
Article is closed for comments.